public async Task <IActionResult> UpdateCanSubAllocation(int id, [FromBody] CanSubAllocationResource canSubAllocationResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var canSubAllocation = await _unitOfWork.Allocations.GetCanSubAllocation(id); if (canSubAllocation == null) { return(NotFound()); } _mapper.Map <CanSubAllocationResource, CanSubAllocation>(canSubAllocationResource, canSubAllocation); canSubAllocation.LastUpdateUserNEDId = "system"; canSubAllocation.LastUpdateDateTime = DateTime.UtcNow; await _unitOfWork.Complete(); return(await GetCanSubAllocation(canSubAllocation.CanSubAllocationId)); }
public async Task <IActionResult> AddCanSubAllocation([FromBody] CanSubAllocationResource canSubAllocationResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var canSubAllocation = _mapper.Map <CanSubAllocationResource, CanSubAllocation>(canSubAllocationResource); canSubAllocation.Status = Status.Active; canSubAllocation.StatusUpdateUserNEDId = "system"; canSubAllocation.StatusUpdateDateTime = DateTime.UtcNow; canSubAllocation.CreateUserNEDId = "system"; canSubAllocation.CreateDateTime = DateTime.UtcNow; _unitOfWork.Allocations.AddCanSubAllocation(canSubAllocation); await _unitOfWork.Complete(); return(await GetCanSubAllocation(canSubAllocation.CanSubAllocationId)); }