Document_Manager #129
@ -1,5 +1,4 @@
|
||||
using Marco.Pms.Model.Dtos.Directory;
|
||||
using Marco.Pms.Model.Utilities;
|
||||
using Marco.Pms.Services.Service.ServiceInterfaces;
|
||||
using MarcoBMS.Services.Helpers;
|
||||
using MarcoBMS.Services.Service;
|
||||
@ -18,14 +17,16 @@ namespace Marco.Pms.Services.Controllers
|
||||
private readonly IDirectoryService _directoryService;
|
||||
private readonly UserHelper _userHelper;
|
||||
private readonly ILoggingService _logger;
|
||||
private readonly ISignalRService _signalR;
|
||||
private readonly Guid tenantId;
|
||||
|
||||
public DirectoryController(IDirectoryService directoryHelper, UserHelper userHelper, ILoggingService logger)
|
||||
public DirectoryController(IDirectoryService directoryHelper, UserHelper userHelper, ILoggingService logger, ISignalRService signalR)
|
||||
{
|
||||
_directoryService = directoryHelper;
|
||||
_userHelper = userHelper;
|
||||
_logger = logger;
|
||||
tenantId = userHelper.GetTenantId();
|
||||
_signalR = signalR;
|
||||
}
|
||||
#region =================================================================== Contact APIs ===================================================================
|
||||
|
||||
@ -53,37 +54,16 @@ namespace Marco.Pms.Services.Controllers
|
||||
var response = await _directoryService.GetListOfContactsOld(search, active, filterDto, projectId);
|
||||
|
||||
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
return StatusCode(response.StatusCode, response);
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("contact-bucket/{bucketId}")]
|
||||
public async Task<IActionResult> GetContactsListByBucketId(Guid bucketId)
|
||||
{
|
||||
var response = await _directoryService.GetContactsListByBucketId(bucketId);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
var response = await _directoryService.GetContactsListByBucketIdAsync(bucketId, tenantId, loggedInEmployee);
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
[HttpGet("profile/{id}")]
|
||||
@ -109,51 +89,42 @@ namespace Marco.Pms.Services.Controllers
|
||||
{
|
||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
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);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> UpdateContact(Guid id, [FromBody] UpdateContactDto updateContact)
|
||||
{
|
||||
var response = await _directoryService.UpdateContact(id, updateContact);
|
||||
if (response.StatusCode == 200)
|
||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
var response = await _directoryService.UpdateContactAsync(id, updateContact, tenantId, loggedInEmployee);
|
||||
if (response.Success)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory", Response = response.Data };
|
||||
await _signalR.SendNotificationAsync(notification);
|
||||
}
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
[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);
|
||||
if (response.StatusCode == 200)
|
||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
var response = await _directoryService.DeleteContactAsync(id, active, tenantId, loggedInEmployee);
|
||||
if (response.Success)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory", Response = id };
|
||||
await _signalR.SendNotificationAsync(notification);
|
||||
}
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
#endregion
|
||||
|
||||
// -------------------------------- Contact Notes --------------------------------
|
||||
#region =================================================================== Contact Notes APIs ===================================================================
|
||||
|
||||
[HttpGet("notes")]
|
||||
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);
|
||||
}
|
||||
|
||||
// -------------------------------- Bucket --------------------------------
|
||||
#endregion
|
||||
|
||||
#region =================================================================== Bucket APIs ===================================================================
|
||||
|
||||
[HttpGet("buckets")]
|
||||
public async Task<IActionResult> GetBucketList()
|
||||
{
|
||||
var response = await _directoryService.GetBucketList();
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
var response = await _directoryService.GetBucketListAsync(tenantId, loggedInEmployee);
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
[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
|
||||
.SelectMany(v => v.Errors)
|
||||
.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);
|
||||
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory_Buckets", Response = response.Data };
|
||||
await _signalR.SendNotificationAsync(notification);
|
||||
}
|
||||
return StatusCode(response.StatusCode, response);
|
||||
|
||||
}
|
||||
|
||||
[HttpPut("bucket/{id}")]
|
||||
public async Task<IActionResult> UpdateBucket(Guid id, [FromBody] UpdateBucketDto bucketDto)
|
||||
{
|
||||
var response = await _directoryService.UpdateBucket(id, bucketDto);
|
||||
if (response.StatusCode == 200)
|
||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
var response = await _directoryService.UpdateBucketAsync(id, bucketDto, tenantId, loggedInEmployee);
|
||||
if (response.Success)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory_Buckets", Response = response.Data };
|
||||
await _signalR.SendNotificationAsync(notification);
|
||||
}
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
[HttpPost("assign-bucket/{bucketId}")]
|
||||
public async Task<IActionResult> AssignBucket(Guid bucketId, [FromBody] List<AssignBucketDto> assignBuckets)
|
||||
{
|
||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
var response = await _directoryService.AssignBucket(bucketId, assignBuckets);
|
||||
if (response.StatusCode == 200)
|
||||
if (response.Success)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory_Buckets", Response = response.Data };
|
||||
await _signalR.SendNotificationAsync(notification);
|
||||
}
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
[HttpDelete("bucket/{id}")]
|
||||
public async Task<IActionResult> DeleteBucket(Guid id)
|
||||
{
|
||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
var response = await _directoryService.DeleteBucket(id);
|
||||
if (response.StatusCode == 200)
|
||||
if (response.Success)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Directory_Buckets", Response = id };
|
||||
await _signalR.SendNotificationAsync(notification);
|
||||
}
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -90,6 +90,7 @@ namespace Marco.Pms.Services.MappingProfiles
|
||||
CreateMap<ContactTagMaster, ContactTagVM>();
|
||||
|
||||
CreateMap<Bucket, BucketVM>();
|
||||
CreateMap<Bucket, AssignBucketVM>();
|
||||
|
||||
CreateMap<ContactNote, ContactNoteVM>()
|
||||
.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>> 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>> GetOrganizationListAsync(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>> DeleteContact(Guid id, bool active);
|
||||
Task<ApiResponse<object>> UpdateContactAsync(Guid id, UpdateContactDto updateContact, Guid tenantId, Employee loggedInEmployee);
|
||||
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>> GetNoteListByContactId(Guid id, bool active);
|
||||
Task<ApiResponse<object>> CreateContactNote(CreateContactNoteDto noteDto);
|
||||
Task<ApiResponse<object>> UpdateContactNote(Guid id, UpdateContactNoteDto noteDto);
|
||||
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>> DeleteBucket(Guid id);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user