private bool Validate(TruckModel truckModel) { if (dbContext.Trucks.Any(x => x.Name == truckModel.Name && x.Id != truckModel.Id.ToString())) { base.HandleError(truckModel, CommonLayer.LookUps.ErrorType.Business, null, string.Format(Resources.AlreadyExists, truckModel.GetDisplayName(x => x.Name)), truckModel.nameof(x => x.Name)); } return(truckModel.HasErrorByType()); }
public ActionResult Delete(TruckModel truckModel) { using (TruckBAL truckBAL = new TruckBAL(ContextInfo)) { truckBAL.Delete(truckModel); if (truckModel.HasErrorByType()) { truckBAL.GetTruckModel(truckModel); // truckBAL.PrepareTruckModel(truckModel); } } return(View(truckModel)); }
public ActionResult Create(TruckModel truckModel) { ModelState.Clear <TruckModel>(x => x.DriverModel); using (TruckBAL truckBAL = new TruckBAL(ContextInfo)) { if (ModelState.IsValid) { truckBAL.Create(truckModel); } if (truckModel.HasErrorByType(LMYFrameWorkMVC.Common.LookUps.ErrorType.Critical) || truckModel.HasSuccess(LMYFrameWorkMVC.Common.LookUps.SuccessType.Full)) { return(base.RedirectToActionWithData(new Dictionary <string, object> { { "baseModel", truckModel } })); } truckBAL.PrepareTruckModel(truckModel); } return(View("Create", truckModel)); }
private bool ValidateDelete(TruckModel truckModel) { return(truckModel.HasErrorByType()); }