Added DirectoryHelper in helper folder
This commit is contained in:
parent
b5ce7eb73f
commit
58b0a3fbaa
@ -6,7 +6,8 @@
|
||||
public string? Name { get; set; }
|
||||
public List<CreateContactPhoneDto>? ContactPhones { 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? Organization { get; set; }
|
||||
public string? Address { get; set; }
|
||||
|
@ -7,6 +7,7 @@
|
||||
public string? Name { get; set; }
|
||||
public List<UpdateContactPhoneDto>? ContactPhones { get; set; }
|
||||
public List<UpdateContactEmailDto>? ContactEmails { get; set; }
|
||||
public List<Guid>? BucketIds { get; set; }
|
||||
public Guid ContactCategoryId { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Organization { get; set; }
|
||||
|
@ -8,7 +8,7 @@ namespace Marco.Pms.Model.Mapper
|
||||
{
|
||||
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
|
||||
@ -19,6 +19,8 @@ namespace Marco.Pms.Model.Mapper
|
||||
Description = createContactDto.Description ?? string.Empty,
|
||||
Organization = createContactDto?.Organization ?? string.Empty,
|
||||
Address = createContactDto != null ? createContactDto.Address : string.Empty,
|
||||
CreatedById = employeeId,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
|
@ -1,26 +1,25 @@
|
||||
using Marco.Pms.DataAccess.Data;
|
||||
using Marco.Pms.Model.Dtos.Directory;
|
||||
using MarcoBMS.Services.Helpers;
|
||||
using Marco.Pms.Model.Dtos.Directory;
|
||||
using Marco.Pms.Model.Utilities;
|
||||
using Marco.Pms.Services.Helpers;
|
||||
using MarcoBMS.Services.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Marco.Pms.Services.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
|
||||
public class DirectoryController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly DirectoryHelper _directoryHelper;
|
||||
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;
|
||||
_userHelper = userHelper;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -32,10 +31,21 @@ namespace Marco.Pms.Services.Controllers
|
||||
[HttpPost]
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user