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); } } }
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); }
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); }
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(); } }
/// <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); }
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); }
public bool DeleteModel(Model model) { try { _modelRepository.Delete(model); return(true); } catch (Exception ex) { return(false); } }
/// <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)); } }
/// <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); }
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")); } }
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()); }
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()); } }
public void Delete(TModel model) => _repository.Delete(model);
public void RemoveModel(int id) { _modelRepository.Delete(id); }
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); }
public void Delete(Guid id) { _modelRepository.Delete(new Model(id)); }