Example #1
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                if (id < 1)
                {
                    return(BadRequest());
                }

                var isExists = await _modelRepository.isExists(id);

                if (!isExists)
                {
                    return(NotFound());
                }

                var model = await _modelRepository.FindById(id);

                var isSuccess = await _modelRepository.Delete(model);

                if (!isSuccess)
                {
                    return(InternalError($"Delete failed"));
                }
                return(NoContent());
            }
            catch (Exception e)
            {
                return(InternalError($"{e.Message} - {e.InnerException}"));
            }
        }
        public async Task <Response> Delete(int idModel)
        {
            Response response = new Response();

            if (idModel < 0)
            {
                response.Errors.Add("ID Inválido!");
            }
            if (response.HasErrors())
            {
                return(response);
            }
            else
            {
                try
                {
                    return(response = await _iModelRepository.Delete(idModel));
                }
                catch (Exception ex)
                {
                    _log.Error(ex + "\nStackTrace: " + ex.StackTrace);
                    response.Errors.Add("DataBase error, contact the system owner");
                    return(response);
                }
            }
        }
Example #3
0
 public void DeleteModel(Model item)
 {
     if (_stockRepository.GetMany(m => m.ModelId == item.ModelId).Any())
     {
         throw new BusinessRuleException("", "Model has a stock history and can no be removed!");
     }
     _modelRepository.Delete(item);
 }
Example #4
0
        public void Delete(int?id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("Id wasn't valid");
            }

            modelRepository.Delete(id);
        }
        public void Delete_Test()
        {
            var nombreModelAvant = 4;

            _vehiculeModelsRepository.Delete(new ModelVehicule()
            {
                Id = 3
            });
            Assert.IsTrue(_vehiculeModelsRepository.GetAll().Count == nombreModelAvant - 1);
        }
Example #6
0
        public void Delete(string objectI, string modelC)
        {
            var deleteItem = _modelRepository.Get(m => m.ModelC == modelC && m.ObjectI == objectI);

            if (deleteItem != null)
            {
                _modelRepository.Delete(deleteItem);
                _maintenanceItemDetailService.DeleteItems(objectI, modelC);
                SaveModel();
            }
        }
Example #7
0
        /// <summary>
        /// Processes the given event <paramref name="eventData"/>
        /// </summary>
        /// <param name="eventData">Event data</param>
        public void Handle(StockRemovedEvent eventData)
        {
            var item = _writerRepository.GetById(eventData.AggregateId);

            if (item == null)
            {
                return;
            }

            _writerRepository.Delete(item);
        }
Example #8
0
        public void DeleteModel(VehicleDto vehicleDto)
        {
            // Ovaj automapper config treba abstractat
            var     config = new MapperConfiguration(cfg => { cfg.CreateMap <VehicleDto, VehicleModelEntity>(); });
            IMapper mapper = config.CreateMapper();

            var entity = mapper.Map <VehicleDto, VehicleModelEntity>(vehicleDto);


            _modelRepository.Delete(entity);
        }
Example #9
0
 public bool DeleteModel(Model model)
 {
     try
     {
         _modelRepository.Delete(model);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #10
0
        /// <summary>
        /// Processes the given event <paramref name="eventData"/>
        /// </summary>
        /// <param name="eventData">Event data</param>
        public void Handle(TransactionUndoEvent eventData)
        {
            var item = _writerRepository.GetById(eventData.AggregateId);

            if (item == null)
            {
                return;
            }

            _writerRepository.Delete(item);

            //TODO: Further processing, what must be done when a transaction was reverted?
            //TODO: Revert balance
        }
        public async Task <Response> Delete(int idModel)
        {
            Response response = new Response();

            if (idModel < 0)
            {
                response.Errors.Add("ID Inválido!");
            }
            if (response.HasErrors())
            {
                return(response);
            }
            else
            {
                return(await _iModelRepository.Delete(idModel));
            }
        }
Example #12
0
        /// <summary>
        /// Processes the given event <paramref name="eventData"/>
        /// </summary>
        /// <param name="eventData">Event data</param>
        public void Handle(FeedbackRemovedEvent eventData)
        {
            var item = _writerRepository.GetById(eventData.AggregateId);

            if (item == null)
            {
                return;
            }

            _writerRepository.Delete(item);

            //Proportion
            var proportion = _feedbackProportionRepository.GetById(eventData.AggregateId);

            if (proportion == null)
            {
                throw new EventHandlerException($"No Feedback proportion found for id: {eventData.AggregateId}", typeof(FeedbackAddedEventHandler));
            }

            _feedbackProportionRepository.Delete(proportion);
        }
Example #13
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var response = await _repository.Delete(id);

                if (response != 0)
                {
                    return(Ok("Deleted successfully"));
                }
                else
                {
                    return(BadRequest("An error ocurred, contact IT Staff"));
                }
            }
            catch (Exception e)
            {
                //Log error
                Log.Error(e.Message);
                Log.Error(e.StackTrace);
                return(BadRequest("An error ocurred, contact IT Staff"));
            }
        }
Example #14
0
        public virtual IActionResult Delete(int id)
        {
            var entity = repo.Get(id);

            if (entity == null)
            {
                try
                {
                    HttpContext.Response.StatusCode = 404;
                    return(Json(new { message = $"{typeof(T).Name} not found" }));
                }
                catch (Exception)
                {
                    return(NotFound());
                }
            }
            var deleteSuccessful = repo.Delete(entity);

            if (!deleteSuccessful)
            {
                return(BadRequest($"Error during {typeof(T).Name} deletion"));
            }
            return(new NoContentResult());
        }
Example #15
0
        public async Task <ActionResult> Delete(int id, ModelVM model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var carModel = await _repo.FindById(id);

                var isSuccess = await _repo.Delete(carModel);

                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something went wrong...");
                    return(View(model));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #16
0
 public void Delete(TModel model) =>
 _repository.Delete(model);
Example #17
0
 public void RemoveModel(int id)
 {
     _modelRepository.Delete(id);
 }
Example #18
0
 public void DeleteModel(ModelPivot Model)
 {
     iModelRepository.Delete(Model.Id, Mapper.Map <ModelPivot, GEN_Model>(Model));
     //iModelRepository.Delete(Model.Id);
     SaveModel();
 }
 public void Delete(ModelVehicule model)
 {
     modelRepository.Delete(model);
 }
Example #20
0
 public void Delete(Guid id)
 {
     _modelRepository.Delete(new Model(id));
 }