public void SaveBusinessConstitution(ClientRegistrationModel clientRegistrationModel) { ClientRegistrationModel companyProfile = GetClientModelFromSession(); Session["ClientRegistrationActiveTab"] = GetValueFromRequestParams("currentIndex"); if (Request.IsAjaxRequest()) { companyProfile.ClientBusinessConstitution.BusinessConstitutionId = GetIntValueFromRequestParams("BussinessConstitutionId"); companyProfile.NoOfPartners = GetIntValueFromRequestParams("NoOfClientPartners"); } else { companyProfile.ClientBusinessConstitution.BusinessConstitutionId = GetIntValueFromRequestParams("cmbBusinessContitutions_VI"); companyProfile.NoOfPartners = GetIntValueFromRequestParams("businessConstitutionModel.NoOfClientPartners"); } if (Session["BusinessConstitution"] == null) { Session["BusinessConstitution"] = new BusinessConstitutionModel(); } BusinessConstitutionModel BCModel = new BusinessConstitutionModel(); BCModel.SelectedIndex = companyProfile.ClientBusinessConstitution.BusinessConstitutionId; BCModel.NoOfClientPartners = companyProfile.NoOfPartners; if (Session["ClientPartners"] != null) { companyProfile.ClientPartners = (List <ClientPartnerDetailsDto>)Session["ClientPartners"]; BCModel.ClientPartners = companyProfile.ClientPartners.ToList(); } Session["BusinessConstitution"] = BCModel; companyProfile.businessConstitutionModel = (BusinessConstitutionModel)Session["BusinessConstitution"]; Session["CompanyProfile"] = companyProfile; }
public void CheckForAOValidation(ClientPartnersModel model, string mode) { #region Client Partner if (String.IsNullOrEmpty(model.ClientPartnerAddress.AddressLine1)) { ModelState.AddModelError("erraddr1", ErrorAndValidationMessages.AOReqAddr1); } if (String.IsNullOrEmpty(model.ClientPartnerAddress.PIN)) { ModelState.AddModelError("errreqpin", ErrorAndValidationMessages.AOReqPIN); } if (!String.IsNullOrEmpty(model.ClientPartnerAddress.PIN) && !Regex.IsMatch(model.ClientPartnerAddress.PIN, Constants.REGEXPIN)) { ModelState.AddModelError("errregxpin", ErrorAndValidationMessages.AORegExPIN); } if (model.ClientPartnerContacts != null) { List <ContactDetailsDto> contactDetailsDto = model.ClientPartnerContacts.Where(x => x.ContactNo == null).ToList(); if (contactDetailsDto != null) { foreach (ContactDetailsDto contact in contactDetailsDto) { model.ClientPartnerContacts.Remove(contact); } } if (String.IsNullOrEmpty(Helper.GetMobileNoFromContacts(model.ClientPartnerContacts))) { ModelState.AddModelError("erraonomob", ErrorAndValidationMessages.AOPIReqMobNo); } foreach (ContactDetailsDto contact in model.ClientPartnerContacts) { if (!String.IsNullOrEmpty(contact.ContactNo) && (!Regex.IsMatch(contact.ContactNo, Constants.REGEXCONTACTNO))) { ModelState.AddModelError(contact.ContactNo, ErrorAndValidationMessages.AOPIRegExContactNo); break; } } } if (EditorExtension.GetValue <object>(model.dOBnAgeModellist[0].txtDOBnAgeName) == null) { ModelState.AddModelError("errdob", ErrorAndValidationMessages.AOPIReqCity); } int cityVillageID = 0; if (ComboBoxExtension.GetValue <object>(model.StateDistrictPlacesControlNames[0].PlacesComboName) != null) { cityVillageID = ComboBoxExtension.GetValue <int>(model.StateDistrictPlacesControlNames[0].PlacesComboName); if (cityVillageID <= 0) { ModelState.AddModelError("erraocity", ErrorAndValidationMessages.AOPIReqCity); } } else { ModelState.AddModelError("erraocity", ErrorAndValidationMessages.AOPIReqCity); } int DesignationId = 0; if (ComboBoxExtension.GetValue <object>(model.designationModel[0].DDLDesignations) != null) { DesignationId = ComboBoxExtension.GetValue <int>(model.designationModel[0].DDLDesignations); if (DesignationId <= 0) { ModelState.AddModelError("erraodesignation", ErrorAndValidationMessages.AOPIReqDesignation); } } else { ModelState.AddModelError("erraodesignation", ErrorAndValidationMessages.AOPIReqDesignation); } DateTime dob; if (EditorExtension.GetValue <object>(model.dOBnAgeModellist[0].txtDOBnAgeName) != null) { dob = EditorExtension.GetValue <DateTime>(model.dOBnAgeModellist[0].txtDOBnAgeName); if (dob == null) { ModelState.AddModelError("errreqdesignation", ErrorAndValidationMessages.AOPIReqExDOB); } else { if (dob.Year < Convert.ToInt32(Constants.MINVALIDYEAR)) { ModelState.AddModelError("errregxdesignation", ErrorAndValidationMessages.AOPIRegXExDOB); } } } else { ModelState.AddModelError("errreqdesignation", ErrorAndValidationMessages.AOPIReqExDOB); } ClientRegistrationModel CRModel = null; int AllowedFarewellYearFrom = 0; int AllowedFarewellYearTo = 0; DateTime FarewellDate = Convert.ToDateTime(model.RelievingDate); if (Session["CompanyProfile"] != null && !String.IsNullOrEmpty(mode) && !String.IsNullOrEmpty(cpmode) && FarewellDate != DateTime.MinValue && FarewellDate != Helper.SetDefaultDate()) { CRModel = (ClientRegistrationModel)Session["CompanyProfile"]; if (CRModel.ClientSubscription.SubscriptionPeriodFromDate != DateTime.MinValue && CRModel.ClientSubscription.SubscriptionPeriodToDate != DateTime.MinValue && CRModel.ClientSubscription.SubscriptionPeriod > 0) { int SubscriptionYearFrom = Convert.ToDateTime(CRModel.ClientSubscription.SubscriptionPeriodFromDate).Year; int SubscriptionMonthFrom = Convert.ToDateTime(CRModel.ClientSubscription.SubscriptionPeriodFromDate).Month; int SubscriptionYearTo = Convert.ToDateTime(CRModel.ClientSubscription.SubscriptionPeriodToDate).Year; int SubscriptionMonthTo = Convert.ToDateTime(CRModel.ClientSubscription.SubscriptionPeriodToDate).Month; int CurrentYear = DateTime.Now.Year; int CurrentMonth = DateTime.Now.Month; if (SubscriptionYearFrom > CurrentYear) { AllowedFarewellYearFrom = SubscriptionYearFrom; AllowedFarewellYearTo = SubscriptionYearFrom + 1; } else if ((SubscriptionYearFrom == CurrentYear && SubscriptionYearTo >= CurrentYear) || (SubscriptionYearFrom < CurrentYear && SubscriptionYearTo >= CurrentYear)) { if (CurrentMonth >= 1 && CurrentMonth <= 3) { AllowedFarewellYearFrom = CurrentYear - 1; AllowedFarewellYearTo = CurrentYear; } else { AllowedFarewellYearFrom = CurrentYear; AllowedFarewellYearTo = CurrentYear + 1; } } if (!(FarewellDate.Year >= AllowedFarewellYearFrom && FarewellDate.Year <= AllowedFarewellYearTo)) { ModelState.AddModelError("errreqdesignation", ErrorAndValidationMessages.AOPIFarewellDateError); } } } #endregion #region Client Partner Gardian DateTime DOB = DateTime.MinValue; bool isMinor = false; if (model.dOBnAgeModellist[0].BindDate != DateTime.MinValue) { isMinor = IsMinor(model.dOBnAgeModellist[0].BindDate); } if (model.ClientPartnerGuardian != null && isMinor) { BusinessConstitutionModel BCModel = new BusinessConstitutionModel(); BusinessConstitutionDto BCDto = null; if (Session["BusinessConstitution"] != null) { BCModel = (BusinessConstitutionModel)Session["BusinessConstitution"]; BusinessConstitutionServiceReference.BusinessConstitutionServiceClient BCClient = new BusinessConstitutionServiceReference.BusinessConstitutionServiceClient(); BCDto = BCClient.GetById(BCModel.BusinessConstitutionId); } List <ClientPartnerDetailsDto> CPDtos = new List <ClientPartnerDetailsDto>(); if (Session["ClientPartners"] != null) { CPDtos = ((List <ClientPartnerDetailsDto>)Session["ClientPartners"]); } bool IsMinorAllowed = true; if (BCDto != null) { if (BCDto.BusinessConstitutionName.Contains("Sole")) { ModelState.AddModelError("errgminors", ErrorAndValidationMessages.ErrorMinorSPClientPartner); IsMinorAllowed = false; } else { int TotalMinorAdded = CPDtos.Where(x => x.ClientPartnerGuardian != null).ToList().Count; if ((BCModel.NoOfClientPartners - TotalMinorAdded) <= 2) { ModelState.AddModelError("errgminors", ErrorAndValidationMessages.ErrorMinorClientPartner); IsMinorAllowed = false; } } } if (IsMinorAllowed) { if (String.IsNullOrEmpty(model.ClientPartnerGuardian.GuardianName)) { ModelState.AddModelError("errgnamereq", ErrorAndValidationMessages.GardianReqName); } if (!String.IsNullOrEmpty(model.ClientPartnerGuardian.GuardianName) && !Regex.IsMatch(model.ClientPartnerGuardian.GuardianName, Constants.REGXNAME)) { ModelState.AddModelError("errregxgnameregx", ErrorAndValidationMessages.GardianReqgExName); } if (String.IsNullOrEmpty(model.ClientPartnerGuardian.ClientPartnerGuardianAddress.AddressLine1)) { ModelState.AddModelError("errreqgaddr1", ErrorAndValidationMessages.AOGReqAddr1); } if (String.IsNullOrEmpty(model.ClientPartnerGuardian.PAN)) { ModelState.AddModelError("errreqgPAN", ErrorAndValidationMessages.AOGReqPAN); } if (!String.IsNullOrEmpty(model.ClientPartnerGuardian.PAN) && !Regex.IsMatch(model.ClientPartnerGuardian.PAN, Constants.REGEXPAN)) { ModelState.AddModelError("errregxgPAN", ErrorAndValidationMessages.AOGRegExPAN); } if (String.IsNullOrEmpty(model.ClientPartnerGuardian.ClientPartnerGuardianAddress.PIN)) { ModelState.AddModelError("errreqgpin", ErrorAndValidationMessages.AOGReqPIN); } if (!String.IsNullOrEmpty(model.ClientPartnerGuardian.ClientPartnerGuardianAddress.PIN) && !Regex.IsMatch(model.ClientPartnerGuardian.ClientPartnerGuardianAddress.PIN, Constants.REGEXPIN)) { ModelState.AddModelError("errregxgpin", ErrorAndValidationMessages.AOGRegExPIN); } if (String.IsNullOrEmpty(model.ClientPartnerGuardian.Email1)) { ModelState.AddModelError("errreqgemail1", ErrorAndValidationMessages.AOGReqEmail1); } if (!String.IsNullOrEmpty(model.ClientPartnerGuardian.Email1) && !Regex.IsMatch(model.ClientPartnerGuardian.Email1, Constants.REGEXEMAIL)) { ModelState.AddModelError("errregxgemail1", ErrorAndValidationMessages.AOGRegExEmail1); } if (!String.IsNullOrEmpty(model.ClientPartnerGuardian.Email2) && !Regex.IsMatch(model.ClientPartnerGuardian.Email2, Constants.REGEXEMAIL)) { ModelState.AddModelError("errregxgemail2", ErrorAndValidationMessages.AOGRegExEmail2); } //if (!String.IsNullOrEmpty(model.ClientPartnerGuardian.UID) && !Regex.IsMatch(model.ClientPartnerGuardian.UID, Constants.REGEXUID)) //{ // ModelState.AddModelError("errregxguid", ErrorAndValidationMessages.AOGRegExUID); //} if (model.ClientPartnerGuardian.ClientPartnerGuardianContacts != null) { List <ContactDetailsDto> contactDetailsDto = model.ClientPartnerGuardian.ClientPartnerGuardianContacts.Where(x => x.ContactNo == null).ToList(); if (contactDetailsDto != null) { foreach (ContactDetailsDto contact in contactDetailsDto) { model.ClientPartnerGuardian.ClientPartnerGuardianContacts.Remove(contact); } } if (String.IsNullOrEmpty(Helper.GetMobileNoFromContacts(model.ClientPartnerGuardian.ClientPartnerGuardianContacts))) { ModelState.AddModelError("errreqgmob", ErrorAndValidationMessages.AOGReqMobNo); } foreach (ContactDetailsDto contact in model.ClientPartnerGuardian.ClientPartnerGuardianContacts) { if (!String.IsNullOrEmpty(contact.ContactNo) && (!Regex.IsMatch(contact.ContactNo, Constants.REGEXCONTACTNO))) { ModelState.AddModelError(contact.ContactNo, ErrorAndValidationMessages.AOPIRegExContactNo); break; } } } if (ComboBoxExtension.GetValue <object>(model.StateDistrictPlacesControlNames[1].PlacesComboName) != null) { cityVillageID = ComboBoxExtension.GetValue <int>(model.StateDistrictPlacesControlNames[1].PlacesComboName); if (cityVillageID <= 0) { ModelState.AddModelError("errreqgcity", ErrorAndValidationMessages.AOGPIReqCity); } } else { ModelState.AddModelError("errreqgcity", ErrorAndValidationMessages.AOGPIReqCity); } } } #endregion }