Beispiel #1
0
        public async Task <OutputResponse> Update(PatientLocationMovementDTO movement)
        {
            var movementToUpdate = await _context.PatientLocationMovements.FirstOrDefaultAsync(x => x.MovementId.Equals(movement.MovementId));

            if (movementToUpdate == null)
            {
                return(new OutputResponse
                {
                    IsErrorOccured = true,
                    Message = "Patient location movement specified does not exist, update cancelled"
                });
            }

            //update details
            movementToUpdate.DistrictCode = movement.DistrictCode;
            movementToUpdate.ImagePath    = movement.ImagePath;

            await _context.SaveChangesAsync();

            return(new OutputResponse
            {
                IsErrorOccured = false,
                Message = MessageHelper.UpdateSuccess
            });
        }
        public async Task <IActionResult> Update([FromBody] PatientLocationMovementDTO patientLocationMovement)
        {
            var outputHandler = await _service.Update(patientLocationMovement);

            if (outputHandler.IsErrorOccured)
            {
                return(BadRequest(outputHandler));
            }

            return(Ok(outputHandler));
        }
Beispiel #3
0
        public async Task <OutputResponse> Add(PatientLocationMovementDTO movement)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var mappedMovement = new AutoMapperHelper <PatientLocationMovementDTO, PatientLocationMovements>().MapToObject(movement);
                mappedMovement.DateCreated = DateTime.UtcNow;

                await _context.PatientLocationMovements.AddAsync(mappedMovement);

                await _context.SaveChangesAsync();

                scope.Complete();
            }
            return(new OutputResponse
            {
                IsErrorOccured = false,
                Message = MessageHelper.AddNewSuccess
            });
        }