Exemple #1
0
        private void ProcessRequestDestinationData(IEnumerable <Destination> list, DataOP op)
        {
            if (list == null)
            {
                return;
            }

            foreach (Destination g in list)
            {
                if (DataOP.AddNew == op)
                {
                    g.RequestHeaderId = RequestHeader.Id;
                    _destinationRepository.Add(g);
                }

                if (DataOP.DEL == op)
                {
                    var user = _destinationRepository.GetById(g.Id);
                    _destinationRepository.Delete(user);
                }

                if (DataOP.EDIT == op)
                {
                    _destinationRepository.Update(g);
                }
            }
        }
 public async Task <IActionResult> DeleteDestination([FromRoute] int id)
 {
     repo.Delete(await repo.GetByIdToDelete(id));
     return(StatusCode(200, new {
         response = ApiMessages.RecordDeleted()
     }));
 }
        public async Task <ActionResult> DeleteDestination(int id)
        {
            try
            {
                var OldDestination = await _destinationRepository.GetDestinationById(id);

                if (OldDestination == null)
                {
                    return(NotFound($"Counld not find destination with id {id}"));
                }
                _destinationRepository.Delete(OldDestination);
                if (await _destinationRepository.Save())
                {
                    return(NoContent());
                }
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
            }
            return(BadRequest());
        }
Exemple #4
0
        public async Task <IActionResult> DeleteDestination([FromRoute] int id)
        {
            Destination record = await repo.GetById(id);

            if (record == null)
            {
                LoggerExtensions.LogException(id, logger, ControllerContext, null, null);
                return(StatusCode(404, new {
                    response = ApiMessages.RecordNotFound()
                }));
            }
            try {
                repo.Delete(record);
                return(StatusCode(200, new {
                    response = ApiMessages.RecordDeleted()
                }));
            } catch (DbUpdateException exception) {
                LoggerExtensions.LogException(0, logger, ControllerContext, record, exception);
                return(StatusCode(491, new {
                    response = ApiMessages.RecordInUse()
                }));
            }
        }