Optimized the contact update API, Delete API , Bucket list API, Create Bucket API, Update Bucket API without implementing cache
This commit is contained in:
parent
9e15cf0447
commit
3980c14d72
@ -1,5 +1,4 @@
|
|||||||
using Marco.Pms.Model.Dtos.Directory;
|
using Marco.Pms.Model.Dtos.Directory;
|
||||||
using Marco.Pms.Model.Utilities;
|
|
||||||
using Marco.Pms.Services.Service.ServiceInterfaces;
|
using Marco.Pms.Services.Service.ServiceInterfaces;
|
||||||
using MarcoBMS.Services.Helpers;
|
using MarcoBMS.Services.Helpers;
|
||||||
using MarcoBMS.Services.Service;
|
using MarcoBMS.Services.Service;
|
||||||
@ -18,14 +17,16 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
private readonly IDirectoryService _directoryService;
|
private readonly IDirectoryService _directoryService;
|
||||||
private readonly UserHelper _userHelper;
|
private readonly UserHelper _userHelper;
|
||||||
private readonly ILoggingService _logger;
|
private readonly ILoggingService _logger;
|
||||||
|
private readonly ISignalRService _signalR;
|
||||||
private readonly Guid tenantId;
|
private readonly Guid tenantId;
|
||||||
|
|
||||||
public DirectoryController(IDirectoryService directoryHelper, UserHelper userHelper, ILoggingService logger)
|
public DirectoryController(IDirectoryService directoryHelper, UserHelper userHelper, ILoggingService logger, ISignalRService signalR)
|
||||||
{
|
{
|
||||||
_directoryService = directoryHelper;
|
_directoryService = directoryHelper;
|
||||||
_userHelper = userHelper;
|
_userHelper = userHelper;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
tenantId = userHelper.GetTenantId();
|
tenantId = userHelper.GetTenantId();
|
||||||
|
_signalR = signalR;
|
||||||
}
|
}
|
||||||
#region =================================================================== Contact APIs ===================================================================
|
#region =================================================================== Contact APIs ===================================================================
|
||||||
|
|
||||||
@ -53,37 +54,16 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
var response = await _directoryService.GetListOfContactsOld(search, active, filterDto, projectId);
|
var response = await _directoryService.GetListOfContactsOld(search, active, filterDto, projectId);
|
||||||
|
|
||||||
|
|
||||||
if (response.StatusCode == 200)
|
return StatusCode(response.StatusCode, response);
|
||||||
{
|
|
||||||
return Ok(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 401)
|
|
||||||
{
|
|
||||||
return Unauthorized(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("contact-bucket/{bucketId}")]
|
[HttpGet("contact-bucket/{bucketId}")]
|
||||||
public async Task<IActionResult> GetContactsListByBucketId(Guid bucketId)
|
public async Task<IActionResult> GetContactsListByBucketId(Guid bucketId)
|
||||||
{
|
{
|
||||||
var response = await _directoryService.GetContactsListByBucketId(bucketId);
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
if (response.StatusCode == 200)
|
var response = await _directoryService.GetContactsListByBucketIdAsync(bucketId, tenantId, loggedInEmployee);
|
||||||
{
|
return StatusCode(response.StatusCode, response);
|
||||||
return Ok(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 401)
|
|
||||||
{
|
|
||||||
return Unauthorized(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("profile/{id}")]
|
[HttpGet("profile/{id}")]
|
||||||
@ -109,51 +89,42 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
{
|
{
|
||||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
var response = await _directoryService.CreateContactAsync(createContact, tenantId, loggedInEmployee);
|
var response = await _directoryService.CreateContactAsync(createContact, tenantId, loggedInEmployee);
|
||||||
|
if (response.Success)
|
||||||
|
{
|
||||||
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory", Response = response.Data };
|
||||||
|
await _signalR.SendNotificationAsync(notification);
|
||||||
|
}
|
||||||
return StatusCode(response.StatusCode, response);
|
return StatusCode(response.StatusCode, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
public async Task<IActionResult> UpdateContact(Guid id, [FromBody] UpdateContactDto updateContact)
|
public async Task<IActionResult> UpdateContact(Guid id, [FromBody] UpdateContactDto updateContact)
|
||||||
{
|
{
|
||||||
var response = await _directoryService.UpdateContact(id, updateContact);
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
if (response.StatusCode == 200)
|
var response = await _directoryService.UpdateContactAsync(id, updateContact, tenantId, loggedInEmployee);
|
||||||
|
if (response.Success)
|
||||||
{
|
{
|
||||||
return Ok(response);
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory", Response = response.Data };
|
||||||
}
|
await _signalR.SendNotificationAsync(notification);
|
||||||
else if (response.StatusCode == 404)
|
|
||||||
{
|
|
||||||
return NotFound(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 401)
|
|
||||||
{
|
|
||||||
return Unauthorized(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
}
|
||||||
|
return StatusCode(response.StatusCode, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
public async Task<IActionResult> DeleteContact(Guid id, [FromQuery] bool? active)
|
public async Task<IActionResult> DeleteContact(Guid id, [FromQuery] bool active = false)
|
||||||
{
|
{
|
||||||
var response = await _directoryService.DeleteContact(id, active ?? false);
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
if (response.StatusCode == 200)
|
var response = await _directoryService.DeleteContactAsync(id, active, tenantId, loggedInEmployee);
|
||||||
|
if (response.Success)
|
||||||
{
|
{
|
||||||
return Ok(response);
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory", Response = id };
|
||||||
}
|
await _signalR.SendNotificationAsync(notification);
|
||||||
else if (response.StatusCode == 404)
|
|
||||||
{
|
|
||||||
return NotFound(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
}
|
||||||
|
return StatusCode(response.StatusCode, response);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// -------------------------------- Contact Notes --------------------------------
|
#region =================================================================== Contact Notes APIs ===================================================================
|
||||||
|
|
||||||
[HttpGet("notes")]
|
[HttpGet("notes")]
|
||||||
public async Task<IActionResult> GetListOFAllNotes([FromQuery] Guid? projectId, [FromQuery] int? pageSize, [FromQuery] int pageNumber)
|
public async Task<IActionResult> GetListOFAllNotes([FromQuery] Guid? projectId, [FromQuery] int? pageSize, [FromQuery] int pageNumber)
|
||||||
@ -224,122 +195,71 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------- Bucket --------------------------------
|
#endregion
|
||||||
|
|
||||||
|
#region =================================================================== Bucket APIs ===================================================================
|
||||||
|
|
||||||
[HttpGet("buckets")]
|
[HttpGet("buckets")]
|
||||||
public async Task<IActionResult> GetBucketList()
|
public async Task<IActionResult> GetBucketList()
|
||||||
{
|
{
|
||||||
var response = await _directoryService.GetBucketList();
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
if (response.StatusCode == 200)
|
var response = await _directoryService.GetBucketListAsync(tenantId, loggedInEmployee);
|
||||||
{
|
return StatusCode(response.StatusCode, response);
|
||||||
return Ok(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 401)
|
|
||||||
{
|
|
||||||
return Unauthorized(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("bucket")]
|
[HttpPost("bucket")]
|
||||||
public async Task<IActionResult> CreateBucket(CreateBucketDto bucketDto)
|
public async Task<IActionResult> CreateBucket([FromBody] CreateBucketDto bucketDto)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
var response = await _directoryService.CreateBucketAsync(bucketDto, tenantId, loggedInEmployee);
|
||||||
|
if (response.Success)
|
||||||
{
|
{
|
||||||
var errors = ModelState.Values
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory_Buckets", Response = response.Data };
|
||||||
.SelectMany(v => v.Errors)
|
await _signalR.SendNotificationAsync(notification);
|
||||||
.Select(e => e.ErrorMessage)
|
|
||||||
.ToList();
|
|
||||||
_logger.LogWarning("User sent Invalid Date while marking attendance");
|
|
||||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
|
||||||
}
|
|
||||||
var response = await _directoryService.CreateBucket(bucketDto);
|
|
||||||
if (response.StatusCode == 200)
|
|
||||||
{
|
|
||||||
return Ok(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 409)
|
|
||||||
{
|
|
||||||
return Conflict(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 401)
|
|
||||||
{
|
|
||||||
return Unauthorized(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
}
|
||||||
|
return StatusCode(response.StatusCode, response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("bucket/{id}")]
|
[HttpPut("bucket/{id}")]
|
||||||
public async Task<IActionResult> UpdateBucket(Guid id, [FromBody] UpdateBucketDto bucketDto)
|
public async Task<IActionResult> UpdateBucket(Guid id, [FromBody] UpdateBucketDto bucketDto)
|
||||||
{
|
{
|
||||||
var response = await _directoryService.UpdateBucket(id, bucketDto);
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
if (response.StatusCode == 200)
|
var response = await _directoryService.UpdateBucketAsync(id, bucketDto, tenantId, loggedInEmployee);
|
||||||
|
if (response.Success)
|
||||||
{
|
{
|
||||||
return Ok(response);
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory_Buckets", Response = response.Data };
|
||||||
}
|
await _signalR.SendNotificationAsync(notification);
|
||||||
else if (response.StatusCode == 404)
|
|
||||||
{
|
|
||||||
return NotFound(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 401)
|
|
||||||
{
|
|
||||||
return Unauthorized(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
}
|
||||||
|
return StatusCode(response.StatusCode, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("assign-bucket/{bucketId}")]
|
[HttpPost("assign-bucket/{bucketId}")]
|
||||||
public async Task<IActionResult> AssignBucket(Guid bucketId, [FromBody] List<AssignBucketDto> assignBuckets)
|
public async Task<IActionResult> AssignBucket(Guid bucketId, [FromBody] List<AssignBucketDto> assignBuckets)
|
||||||
{
|
{
|
||||||
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
var response = await _directoryService.AssignBucket(bucketId, assignBuckets);
|
var response = await _directoryService.AssignBucket(bucketId, assignBuckets);
|
||||||
if (response.StatusCode == 200)
|
if (response.Success)
|
||||||
{
|
{
|
||||||
return Ok(response);
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory_Buckets", Response = response.Data };
|
||||||
}
|
await _signalR.SendNotificationAsync(notification);
|
||||||
else if (response.StatusCode == 404)
|
|
||||||
{
|
|
||||||
return NotFound(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 401)
|
|
||||||
{
|
|
||||||
return Unauthorized(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
}
|
||||||
|
return StatusCode(response.StatusCode, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("bucket/{id}")]
|
[HttpDelete("bucket/{id}")]
|
||||||
public async Task<IActionResult> DeleteBucket(Guid id)
|
public async Task<IActionResult> DeleteBucket(Guid id)
|
||||||
{
|
{
|
||||||
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
var response = await _directoryService.DeleteBucket(id);
|
var response = await _directoryService.DeleteBucket(id);
|
||||||
if (response.StatusCode == 200)
|
if (response.Success)
|
||||||
{
|
{
|
||||||
return Ok(response);
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory_Buckets", Response = id };
|
||||||
}
|
await _signalR.SendNotificationAsync(notification);
|
||||||
else if (response.StatusCode == 404)
|
|
||||||
{
|
|
||||||
return NotFound(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 401)
|
|
||||||
{
|
|
||||||
return Unauthorized(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
}
|
||||||
|
return StatusCode(response.StatusCode, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -90,6 +90,7 @@ namespace Marco.Pms.Services.MappingProfiles
|
|||||||
CreateMap<ContactTagMaster, ContactTagVM>();
|
CreateMap<ContactTagMaster, ContactTagVM>();
|
||||||
|
|
||||||
CreateMap<Bucket, BucketVM>();
|
CreateMap<Bucket, BucketVM>();
|
||||||
|
CreateMap<Bucket, AssignBucketVM>();
|
||||||
|
|
||||||
CreateMap<ContactNote, ContactNoteVM>()
|
CreateMap<ContactNote, ContactNoteVM>()
|
||||||
.ForMember(
|
.ForMember(
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -8,20 +8,24 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces
|
|||||||
{
|
{
|
||||||
Task<ApiResponse<object>> GetListOfContactsAsync(string? search, string? filter, Guid? projectId, bool active, int pageSize, int pageNumber, Guid tenantId, Employee loggedInEmployee);
|
Task<ApiResponse<object>> GetListOfContactsAsync(string? search, string? filter, Guid? projectId, bool active, int pageSize, int pageNumber, Guid tenantId, Employee loggedInEmployee);
|
||||||
Task<ApiResponse<object>> GetListOfContactsOld(string? search, bool active, ContactFilterDto? filterDto, Guid? projectId);
|
Task<ApiResponse<object>> GetListOfContactsOld(string? search, bool active, ContactFilterDto? filterDto, Guid? projectId);
|
||||||
Task<ApiResponse<object>> GetContactsListByBucketId(Guid id);
|
Task<ApiResponse<object>> GetContactsListByBucketIdAsync(Guid bucketId, Guid tenantId, Employee loggedInEmployee);
|
||||||
Task<ApiResponse<object>> GetContactProfileAsync(Guid id, Guid tenantId, Employee loggedInEmployee);
|
Task<ApiResponse<object>> GetContactProfileAsync(Guid id, Guid tenantId, Employee loggedInEmployee);
|
||||||
Task<ApiResponse<object>> GetOrganizationListAsync(Guid tenantId, Employee loggedInEmployee);
|
Task<ApiResponse<object>> GetOrganizationListAsync(Guid tenantId, Employee loggedInEmployee);
|
||||||
Task<ApiResponse<object>> CreateContactAsync(CreateContactDto createContact, Guid tenantId, Employee loggedInEmployee);
|
Task<ApiResponse<object>> CreateContactAsync(CreateContactDto createContact, Guid tenantId, Employee loggedInEmployee);
|
||||||
Task<ApiResponse<object>> UpdateContact(Guid id, UpdateContactDto updateContact);
|
Task<ApiResponse<object>> UpdateContactAsync(Guid id, UpdateContactDto updateContact, Guid tenantId, Employee loggedInEmployee);
|
||||||
Task<ApiResponse<object>> DeleteContact(Guid id, bool active);
|
Task<ApiResponse<object>> DeleteContactAsync(Guid id, bool active, Guid tenantId, Employee loggedInEmployee);
|
||||||
|
|
||||||
|
|
||||||
Task<ApiResponse<object>> GetListOFAllNotes(Guid? projectId, int pageSize, int pageNumber);
|
Task<ApiResponse<object>> GetListOFAllNotes(Guid? projectId, int pageSize, int pageNumber);
|
||||||
Task<ApiResponse<object>> GetNoteListByContactId(Guid id, bool active);
|
Task<ApiResponse<object>> GetNoteListByContactId(Guid id, bool active);
|
||||||
Task<ApiResponse<object>> CreateContactNote(CreateContactNoteDto noteDto);
|
Task<ApiResponse<object>> CreateContactNote(CreateContactNoteDto noteDto);
|
||||||
Task<ApiResponse<object>> UpdateContactNote(Guid id, UpdateContactNoteDto noteDto);
|
Task<ApiResponse<object>> UpdateContactNote(Guid id, UpdateContactNoteDto noteDto);
|
||||||
Task<ApiResponse<object>> DeleteContactNote(Guid id, bool active);
|
Task<ApiResponse<object>> DeleteContactNote(Guid id, bool active);
|
||||||
Task<ApiResponse<object>> GetBucketList();
|
|
||||||
Task<ApiResponse<object>> CreateBucket(CreateBucketDto bucketDto);
|
|
||||||
Task<ApiResponse<object>> UpdateBucket(Guid id, UpdateBucketDto bucketDto);
|
Task<ApiResponse<object>> GetBucketListAsync(Guid tenantId, Employee loggedInEmployee);
|
||||||
|
Task<ApiResponse<object>> CreateBucketAsync(CreateBucketDto bucketDto, Guid tenantId, Employee loggedInEmployee);
|
||||||
|
Task<ApiResponse<object>> UpdateBucketAsync(Guid id, UpdateBucketDto bucketDto, Guid tenantId, Employee loggedInEmployee);
|
||||||
Task<ApiResponse<object>> AssignBucket(Guid bucketId, List<AssignBucketDto> assignBuckets);
|
Task<ApiResponse<object>> AssignBucket(Guid bucketId, List<AssignBucketDto> assignBuckets);
|
||||||
Task<ApiResponse<object>> DeleteBucket(Guid id);
|
Task<ApiResponse<object>> DeleteBucket(Guid id);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user