public async Task <OutputResponse> Update(PatientFacilityMovementDTO movement) { var movementToUpdate = await _context.PatientFacilityMovements.FirstOrDefaultAsync( x => x.MovementId.Equals(movement.MovementId)); if (movementToUpdate == null) { return(new OutputResponse { IsErrorOccured = true, Message = "Patient facility movement specified does not exist, update cancelled" }); } //update details movementToUpdate.FromDataCenterId = movement.FromDataCenterId; movementToUpdate.ToDataCenterId = movement.ToDataCenterId; await _context.SaveChangesAsync(); return(new OutputResponse { IsErrorOccured = false, Message = MessageHelper.UpdateSuccess }); }
public async Task <IActionResult> Update([FromBody] PatientFacilityMovementDTO patientFacilityMovement) { var outputHandler = await _service.Update(patientFacilityMovement); if (outputHandler.IsErrorOccured) { return(BadRequest(outputHandler)); } return(Ok(outputHandler)); }
public async Task <OutputResponse> Add(PatientFacilityMovementDTO movement) { using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { var mappedMovement = new AutoMapperHelper <PatientFacilityMovementDTO, PatientFacilityMovements>().MapToObject(movement); mappedMovement.DateCreated = DateTime.UtcNow; await _context.PatientFacilityMovements.AddAsync(mappedMovement); await _context.SaveChangesAsync(); scope.Complete(); } return(new OutputResponse { IsErrorOccured = false, Message = MessageHelper.AddNewSuccess }); }