예제 #1
0
        private bool Validate(USAStateModel uSAStateModel)
        {
            if (dbContext.USAStates.Any(x => x.Name == uSAStateModel.Name && x.Id != uSAStateModel.Id.ToString()))
            {
                base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Business, null, string.Format(Resources.AlreadyExists, uSAStateModel.GetDisplayName(x => x.Name)), uSAStateModel.nameof(x => x.Name));
            }


            if (dbContext.USAStates.Any(x => x.StateCode.ToLower() == uSAStateModel.StateCode.ToLower() && x.Id != uSAStateModel.Id.ToString()))
            {
                base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Business, null, string.Format(Resources.AlreadyExists, uSAStateModel.GetDisplayName(x => x.StateCode)), uSAStateModel.nameof(x => x.StateCode));
            }

            return(uSAStateModel.HasErrorByType());
        }
예제 #2
0
        public ActionResult Delete(USAStateModel uSAStateModel)
        {
            using (USAStateBAL uSAStateBAL = new USAStateBAL(ContextInfo))
            {
                uSAStateBAL.Delete(uSAStateModel);

                if (uSAStateModel.HasErrorByType())
                {
                    uSAStateBAL.GetUSAStateModel(uSAStateModel);
                    //     uSAStateBAL.PrepareUSAStateModel(uSAStateModel);
                }
            }

            return(View(uSAStateModel));
        }
예제 #3
0
        public ActionResult Create(USAStateModel uSAStateModel)
        {
            using (USAStateBAL uSAStateBAL = new USAStateBAL(ContextInfo))
            {
                if (ModelState.IsValid)
                {
                    uSAStateBAL.Create(uSAStateModel);
                }

                if (uSAStateModel.HasErrorByType(LMYFrameWorkMVC.Common.LookUps.ErrorType.Critical) || uSAStateModel.HasSuccess(LMYFrameWorkMVC.Common.LookUps.SuccessType.Full))
                {
                    return(base.RedirectToActionWithData(new Dictionary <string, object> {
                        { "baseModel", uSAStateModel }
                    }));
                }

                uSAStateBAL.PrepareUSAStateModel(uSAStateModel);
            }

            return(View("Create", uSAStateModel));
        }
예제 #4
0
 private bool ValidateDelete(USAStateModel uSAStateModel)
 {
     return(uSAStateModel.HasErrorByType());
 }