Created new Api for creating and editing activities
This commit is contained in:
parent
17994bff08
commit
ed449fdf47
@ -62,6 +62,23 @@ namespace Marco.Pms.Services.Controllers
|
||||
return Ok(ApiResponse<object>.SuccessResponse(activityMaster, "Activity created successfully", 200));
|
||||
}
|
||||
|
||||
[HttpPost("edit{id}")]
|
||||
public async Task<IActionResult> UpdateActivity(int id, [FromBody] CreateActivityMasterDto createActivity)
|
||||
{
|
||||
var tenantId = _userHelper.GetTenantId();
|
||||
var employee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
ActivityMaster? activity = await _context.ActivityMasters.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (activity != null) {
|
||||
activity.ActivityName = activity.ActivityName;
|
||||
activity.UnitOfMeasurement = createActivity.UnitOfMeasurement;
|
||||
activity.TenantId = tenantId;
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(ApiResponse<object>.SuccessResponse(activity, "Activity updated successfully", 200));
|
||||
}
|
||||
|
||||
return NotFound(ApiResponse<object>.ErrorResponse("Activity no found", "Activity no found", 404));
|
||||
}
|
||||
|
||||
[HttpPost("edit{id}")]
|
||||
public async Task<IActionResult> UpdateActivity(int id, [FromBody] CreateActivityMasterDto createActivity)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user