private bool Validate(CompanyModel companyModel) { if (dbContext.Companies.Any(x => x.Name == companyModel.Name && x.Id != companyModel.Id.ToString())) { base.HandleError(companyModel, CommonLayer.LookUps.ErrorType.Business, null, string.Format(Resources.AlreadyExists, companyModel.GetDisplayName(x => x.Name)), companyModel.nameof(x => x.Name)); } return(companyModel.HasErrorByType()); }
public ActionResult Delete(CompanyModel companyModel) { using (CompanyBAL companyBAL = new CompanyBAL(ContextInfo)) { companyBAL.Delete(companyModel); if (companyModel.HasErrorByType()) { companyBAL.GetCompanyModel(companyModel); // companyBAL.PrepareCompanyModel(companyModel); } } return(View(companyModel)); }
public ActionResult Create(CompanyModel companyModel) { using (CompanyBAL companyBAL = new CompanyBAL(ContextInfo)) { if (ModelState.IsValid) { companyBAL.Create(companyModel); } if (companyModel.HasErrorByType(LMYFrameWorkMVC.Common.LookUps.ErrorType.Critical) || companyModel.HasSuccess(LMYFrameWorkMVC.Common.LookUps.SuccessType.Full)) { return(base.RedirectToActionWithData(new Dictionary <string, object> { { "baseModel", companyModel } })); } companyBAL.PrepareCompanyModel(companyModel); } return(View("Create", companyModel)); }
private bool ValidateDelete(CompanyModel companyModel) { return(companyModel.HasErrorByType()); }