Compare commits
No commits in common. "0236c87540a958cc0a48dbcd22b14b2fa09bade9" and "99c56bc9ddc93ac811b9df3ee94beb6e52d87618" have entirely different histories.
0236c87540
...
99c56bc9dd
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class CreateBucketDto
|
public class CreateBucketDto
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = string.Empty;
|
public string name { get; set; } = string.Empty;
|
||||||
public string Description { get; set; } = string.Empty;
|
public string description { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,33 +89,5 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
var response = await _directoryHelper.GetBucketList();
|
var response = await _directoryHelper.GetBucketList();
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("bucket")]
|
|
||||||
public async Task<IActionResult> CreateBucket(CreateBucketDto bucketDto)
|
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
var response = await _directoryHelper.CreateBucket(bucketDto);
|
|
||||||
if (response.StatusCode == 200)
|
|
||||||
{
|
|
||||||
return Ok(response);
|
|
||||||
}
|
|
||||||
else if (response.StatusCode == 409)
|
|
||||||
{
|
|
||||||
return Conflict(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BadRequest(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -377,7 +377,7 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
}
|
}
|
||||||
foreach (var contactTag in contactTags)
|
foreach (var contactTag in contactTags)
|
||||||
{
|
{
|
||||||
if (!updatedTagIds.Contains(contactTag.ContactTagtId))
|
if (!updatedTagIds.Contains(contactTag.Id))
|
||||||
{
|
{
|
||||||
_context.ContactTagMappings.Remove(contactTag);
|
_context.ContactTagMappings.Remove(contactTag);
|
||||||
}
|
}
|
||||||
@ -455,42 +455,5 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
_logger.LogInfo("{count} Buckets are fetched by Employee with ID {LoggedInEmployeeId}", bucketVMs.Count, LoggedInEmployee.Id);
|
_logger.LogInfo("{count} Buckets are fetched by Employee with ID {LoggedInEmployeeId}", bucketVMs.Count, LoggedInEmployee.Id);
|
||||||
return ApiResponse<object>.SuccessResponse(bucketVMs, System.String.Format("{0} buckets fetched successfully", bucketVMs.Count), 200);
|
return ApiResponse<object>.SuccessResponse(bucketVMs, System.String.Format("{0} buckets fetched successfully", bucketVMs.Count), 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ApiResponse<object>> CreateBucket(CreateBucketDto bucketDto)
|
|
||||||
{
|
|
||||||
Guid tenantId = _userHelper.GetTenantId();
|
|
||||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
|
||||||
if (bucketDto != null)
|
|
||||||
{
|
|
||||||
var existingBucket = await _context.Buckets.FirstOrDefaultAsync(b => b.Name == bucketDto.Name);
|
|
||||||
if (existingBucket != null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Employee ID {LoggedInEmployeeId} attempted to create an existing bucket.", LoggedInEmployee.Id);
|
|
||||||
return ApiResponse<object>.ErrorResponse("Bucket already existed", "Bucket already existed", 409);
|
|
||||||
}
|
|
||||||
Bucket bucket = new Bucket
|
|
||||||
{
|
|
||||||
Name = bucketDto.Name,
|
|
||||||
Description = bucketDto.Description,
|
|
||||||
TenantId = tenantId
|
|
||||||
};
|
|
||||||
_context.Buckets.Add(bucket);
|
|
||||||
|
|
||||||
EmployeeBucketMapping employeeBucket = new EmployeeBucketMapping
|
|
||||||
{
|
|
||||||
EmployeeId = LoggedInEmployee.Id,
|
|
||||||
BucketId = bucket.Id
|
|
||||||
};
|
|
||||||
|
|
||||||
_context.EmployeeBucketMappings.Add(employeeBucket);
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
BucketVM bucketVM = bucket.ToBucketVMFromBucket();
|
|
||||||
_logger.LogInfo("Employee Id {LoggedInEmployeeId} creayted new bucket {BucketId}", LoggedInEmployee.Id, bucket.Id);
|
|
||||||
return ApiResponse<object>.SuccessResponse(bucketVM, "Bucket Created SuccessFully", 200);
|
|
||||||
}
|
|
||||||
_logger.LogWarning("Employee with ID {LoggedInEmployeeId} sended empty payload", LoggedInEmployee.Id);
|
|
||||||
return ApiResponse<object>.ErrorResponse("User Send empty Payload", "User Send empty Payload", 400);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user