Added DirectoryHelper in helper folder
This commit is contained in:
parent
7c37007a07
commit
e3dfcb4ee0
@ -6,7 +6,8 @@
|
|||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public List<CreateContactPhoneDto>? ContactPhones { get; set; }
|
public List<CreateContactPhoneDto>? ContactPhones { get; set; }
|
||||||
public List<CreateContactEmailDto>? ContactEmails { get; set; }
|
public List<CreateContactEmailDto>? ContactEmails { get; set; }
|
||||||
public Guid ContactCategoryId { get; set; }
|
public List<Guid>? BucketIds { get; set; }
|
||||||
|
public Guid? ContactCategoryId { get; set; }
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
public string? Organization { get; set; }
|
public string? Organization { get; set; }
|
||||||
public string? Address { get; set; }
|
public string? Address { get; set; }
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public List<UpdateContactPhoneDto>? ContactPhones { get; set; }
|
public List<UpdateContactPhoneDto>? ContactPhones { get; set; }
|
||||||
public List<UpdateContactEmailDto>? ContactEmails { get; set; }
|
public List<UpdateContactEmailDto>? ContactEmails { get; set; }
|
||||||
|
public List<Guid>? BucketIds { get; set; }
|
||||||
public Guid ContactCategoryId { get; set; }
|
public Guid ContactCategoryId { get; set; }
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
public string? Organization { get; set; }
|
public string? Organization { get; set; }
|
||||||
|
@ -8,7 +8,7 @@ namespace Marco.Pms.Model.Mapper
|
|||||||
{
|
{
|
||||||
public static class DirectoryMapper
|
public static class DirectoryMapper
|
||||||
{
|
{
|
||||||
public static Contact ToContactFromCreateContactDto(this CreateContactDto createContactDto, Guid tenantId)
|
public static Contact ToContactFromCreateContactDto(this CreateContactDto createContactDto, Guid tenantId, Guid employeeId)
|
||||||
{
|
{
|
||||||
|
|
||||||
return new Contact
|
return new Contact
|
||||||
@ -19,6 +19,8 @@ namespace Marco.Pms.Model.Mapper
|
|||||||
Description = createContactDto.Description ?? string.Empty,
|
Description = createContactDto.Description ?? string.Empty,
|
||||||
Organization = createContactDto?.Organization ?? string.Empty,
|
Organization = createContactDto?.Organization ?? string.Empty,
|
||||||
Address = createContactDto != null ? createContactDto.Address : string.Empty,
|
Address = createContactDto != null ? createContactDto.Address : string.Empty,
|
||||||
|
CreatedById = employeeId,
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
TenantId = tenantId
|
TenantId = tenantId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
using Marco.Pms.DataAccess.Data;
|
using Marco.Pms.Model.Dtos.Directory;
|
||||||
using Marco.Pms.Model.Dtos.Directory;
|
using Marco.Pms.Model.Utilities;
|
||||||
using MarcoBMS.Services.Helpers;
|
using Marco.Pms.Services.Helpers;
|
||||||
using MarcoBMS.Services.Service;
|
using MarcoBMS.Services.Service;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Marco.Pms.Services.Controllers
|
namespace Marco.Pms.Services.Controllers
|
||||||
{
|
{
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
|
||||||
public class DirectoryController : ControllerBase
|
public class DirectoryController : ControllerBase
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly DirectoryHelper _directoryHelper;
|
||||||
private readonly ILoggingService _logger;
|
private readonly ILoggingService _logger;
|
||||||
private readonly UserHelper _userHelper;
|
|
||||||
|
|
||||||
|
|
||||||
public DirectoryController(ApplicationDbContext context, ILoggingService logger, UserHelper userHelper)
|
public DirectoryController(DirectoryHelper directoryHelper, ILoggingService logger)
|
||||||
{
|
{
|
||||||
_context = context;
|
_directoryHelper = directoryHelper;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_userHelper = userHelper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -32,10 +31,21 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> CreateContact([FromBody] CreateContactDto createContact)
|
public async Task<IActionResult> CreateContact([FromBody] CreateContactDto createContact)
|
||||||
{
|
{
|
||||||
return Ok();
|
if (!ModelState.IsValid)
|
||||||
}
|
|
||||||
{
|
{
|
||||||
|
var errors = ModelState.Values
|
||||||
|
.SelectMany(v => v.Errors)
|
||||||
|
.Select(e => e.ErrorMessage)
|
||||||
|
.ToList();
|
||||||
|
_logger.LogError("User sent Invalid Date while marking attendance");
|
||||||
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
||||||
|
}
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
21
Marco.Pms.Services/Helpers/DirectoryHelper.cs
Normal file
21
Marco.Pms.Services/Helpers/DirectoryHelper.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using Marco.Pms.DataAccess.Data;
|
||||||
|
using MarcoBMS.Services.Helpers;
|
||||||
|
using MarcoBMS.Services.Service;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Services.Helpers
|
||||||
|
{
|
||||||
|
public class DirectoryHelper
|
||||||
|
{
|
||||||
|
private readonly ApplicationDbContext _context;
|
||||||
|
private readonly ILoggingService _logger;
|
||||||
|
private readonly UserHelper _userHelper;
|
||||||
|
|
||||||
|
|
||||||
|
public DirectoryHelper(ApplicationDbContext context, ILoggingService logger, UserHelper userHelper)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_logger = logger;
|
||||||
|
_userHelper = userHelper;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ using Marco.Pms.DataAccess.Data;
|
|||||||
using Marco.Pms.Model.Authentication;
|
using Marco.Pms.Model.Authentication;
|
||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
using Marco.Pms.Model.Utilities;
|
using Marco.Pms.Model.Utilities;
|
||||||
|
using Marco.Pms.Services.Helpers;
|
||||||
using Marco.Pms.Services.Service;
|
using Marco.Pms.Services.Service;
|
||||||
using MarcoBMS.Services.Helpers;
|
using MarcoBMS.Services.Helpers;
|
||||||
using MarcoBMS.Services.Middleware;
|
using MarcoBMS.Services.Middleware;
|
||||||
@ -130,6 +131,7 @@ builder.Services.AddScoped<UserHelper>();
|
|||||||
builder.Services.AddScoped<RolesHelper>();
|
builder.Services.AddScoped<RolesHelper>();
|
||||||
builder.Services.AddScoped<EmployeeHelper>();
|
builder.Services.AddScoped<EmployeeHelper>();
|
||||||
builder.Services.AddScoped<ProjectsHelper>();
|
builder.Services.AddScoped<ProjectsHelper>();
|
||||||
|
builder.Services.AddScoped<DirectoryHelper>();
|
||||||
builder.Services.AddSingleton<ILoggingService, LoggingService>();
|
builder.Services.AddSingleton<ILoggingService, LoggingService>();
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user