예제 #1
0
        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());
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
 private bool ValidateDelete(TruckModel truckModel)
 {
     return(truckModel.HasErrorByType());
 }