public ActionResult ViewAgentDetail(string User_Name, string agentId = "", string ParentId = "") { AgentManagementModel AM = new AgentManagementModel(); if (!string.IsNullOrEmpty(ParentId) && string.IsNullOrEmpty(ParentId.DecryptParameter())) { return(RedirectToAction("Index", new { parent_id = ParentId })); } else { AM.ParentID = ParentId; } if (!string.IsNullOrEmpty(agentId)) { AM.AgentID = agentId.DecryptParameter(); if (!string.IsNullOrEmpty(AM.AgentID)) { AgentManagementCommon AC = buss.GetAgentById(AM.AgentID, User_Name.DecryptParameter()); AM = AC.MapObject <AgentManagementModel>(); AM.AgentID = AM.AgentID.EncryptParameter(); AM.UserID = AM.UserID.EncryptParameter(); AM.ParentID = AM.ParentID.EncryptParameter(); var pprovince = LoadDropdownList("province") as Dictionary <string, string>; AM.AgentProvince = pprovince.ContainsKey(AM.AgentProvince) ? pprovince.FirstOrDefault(x => x.Key == AM.AgentProvince).Value : AM.AgentProvince; return(View(AM)); } } this.ShowPopup(1, "Error"); return(RedirectToAction("Index")); }
public ActionResult ManageAgent(string User_Name, string agentId = "", string ParentId = "") { AgentManagementModel AM = new AgentManagementModel(); if (!string.IsNullOrEmpty(ParentId) && string.IsNullOrEmpty(ParentId.DecryptParameter())) { return(RedirectToAction("Index", new { parent_id = ParentId })); } else { AM.ParentID = ParentId; } if (!string.IsNullOrEmpty(agentId)) { AM.AgentID = agentId.DecryptParameter(); if (!string.IsNullOrEmpty(AM.AgentID)) { AgentManagementCommon AC = buss.GetAgentById(AM.AgentID, User_Name.DecryptParameter()); AM = AC.MapObject <AgentManagementModel>(); AM.AgentID = AM.AgentID.EncryptParameter(); AM.UserID = AM.UserID.EncryptParameter(); AM.ParentID = AM.ParentID.EncryptParameter(); RemoveupdateValidation(AM); } } if (string.IsNullOrEmpty(agentId)) { AM.AgentCountry = "Nepal"; } LoadDropDownList(AM); return(View(AM)); }
public void RemoveupdateValidation(AgentManagementModel AMM) { ModelState.Remove("Password"); ModelState.Remove("confirmPassword"); ModelState.Remove("FirstName"); ModelState.Remove("MiddleName"); ModelState.Remove("LastName"); ModelState.Remove("UserMobileNumber"); ModelState.Remove("UserEmail"); }
public void LoadDropDownList(AgentManagementModel agentmodel) { //Manage Distributor ViewBag.AgentCountryList = ApplicationUtilities.SetDDLValue(LoadDropdownList("country"), agentmodel.AgentCountry, "--select Country--"); ViewBag.AgentProvinceList = ApplicationUtilities.SetDDLValue(LoadDropdownList("province", agentmodel.AgentCountry), agentmodel.AgentProvince, "--select Province--"); ViewBag.AgentDistrictList = ApplicationUtilities.SetDDLValue(LoadDropdownList("districtList", agentmodel.AgentProvince) as Dictionary <string, string>, agentmodel.AgentDistrict, "--select District--"); ViewBag.AgentVDC_MuncipilityList = ApplicationUtilities.SetDDLValue(LoadDropdownList("vdc_muncipality", agentmodel.AgentDistrict), agentmodel.AgentVDC_Muncipality, "--select VDC Muncipality--"); ViewBag.IssueDistrictList = ApplicationUtilities.SetDDLValue(LoadDropdownList("issuedistrict"), agentmodel.ContactPersonIdIssueDistrict, "--Select District--"); ViewBag.DoctypeList = ApplicationUtilities.SetDDLValue(LoadDropdownList("doctype"), agentmodel.ContactPersonIdType, "--Select Document Type--"); }
public void RemoveBusinessValidation(AgentManagementModel AMM) { ModelState.Remove("AgentPhoneNumber"); ModelState.Remove("AgentMobileNumber"); ModelState.Remove("AgentEmail"); ModelState.Remove("AgentWebUrl"); ModelState.Remove("AgentRegistrationNumber"); ModelState.Remove("AgentPanNumber"); ModelState.Remove("AgentContractDate"); ModelState.Remove("AgentContractDate_BS"); ModelState.Remove("AgentRegistrationCertificate"); ModelState.Remove("AgentPanCertificate"); ModelState.Remove("ContactPersonName"); ModelState.Remove("ContactPersonMobileNumber"); ModelState.Remove("ContactPersonIdType"); ModelState.Remove("ContactPersonIdNumber"); ModelState.Remove("ContactPersonIdIssueCountry"); ModelState.Remove("ContactPersonIdIssueDistrict"); ModelState.Remove("ContactPersonIdIssueDate"); ModelState.Remove("ContactPersonIdIssueDate_BS"); ModelState.Remove("ContactPersonIdExpiryDate"); ModelState.Remove("ContactPersonIdExpiryDate_BS"); AMM.AgentPhoneNumber = ""; AMM.AgentMobileNumber = ""; AMM.AgentEmail = ""; AMM.AgentWebUrl = ""; AMM.AgentRegistrationNumber = ""; AMM.AgentPanNumber = ""; AMM.AgentContractDate = ""; AMM.AgentContractDate_BS = ""; AMM.ContactPersonName = ""; AMM.ContactPersonMobileNumber = ""; AMM.ContactPersonIdType = ""; AMM.ContactPersonIdNumber = ""; AMM.ContactPersonIdIssueCountry = ""; AMM.ContactPersonIdIssueDistrict = ""; AMM.ContactPersonIdIssueDate = ""; AMM.ContactPersonIdIssueDate_BS = ""; AMM.ContactPersonIdExpiryDate = ""; AMM.ContactPersonIdExpiryDate_BS = ""; }
public ActionResult ManageAgent(AgentManagementModel agentModel, HttpPostedFileBase Agent_Logo, HttpPostedFileBase Pan_Certiticate, HttpPostedFileBase Registration_Certificate, string changepassword = "") { var Agent_LogoPath = ""; var Pan_CertiticatePath = ""; var Registration_CertificatePath = ""; ModelState.Remove("AgentContractDate_BS"); LoadDropDownList(agentModel); if (!string.IsNullOrEmpty(agentModel.AgentID)) { agentModel.AgentID = agentModel.AgentID.DecryptParameter(); ModelState.Remove("userName"); if (changepassword.ToUpper() != "ON") { RemoveupdateValidation(agentModel); agentModel.Password = ""; agentModel.ConfirmPassword = ""; } } if (agentModel.AgentOperationType.ToUpper() != "BUSINESS") { agentModel.AgentMobileNumber = agentModel.UserMobileNumber; agentModel.AgentEmail = agentModel.UserEmail; RemoveBusinessValidation(agentModel); } if (ModelState.IsValid) { AgentManagementCommon AC = new AgentManagementCommon(); AC = agentModel.MapObject <AgentManagementCommon>(); if (!string.IsNullOrEmpty(AC.AgentID)) { if (string.IsNullOrEmpty(AC.AgentID)) { return(View(agentModel)); } //if (string.IsNullOrEmpty(changepassword)) //{ // AC.Password = ""; // AC.ConfirmPassword = ""; //} AC.AgentID = AC.AgentID;//.DecryptParameter(); AC.UserID = AC.UserID.DecryptParameter(); } if (!string.IsNullOrEmpty(AC.ParentID)) { if (string.IsNullOrEmpty(AC.ParentID.DecryptParameter())) { return(View(agentModel)); } AC.ParentID = AC.ParentID.DecryptParameter(); } AC.ActionUser = ApplicationUtilities.GetSessionValue("UserName").ToString(); AC.IpAddress = ApplicationUtilities.GetIP(); if (Agent_Logo != null) { var contentType = Agent_Logo.ContentType; var allowedExtensions = new[] { ".jpg", ".png", ".jpeg" }; var fileName = Path.GetFileName(Agent_Logo.FileName); String timeStamp = DateTime.Now.ToString(); var ext = Path.GetExtension(Agent_Logo.FileName); if (Agent_Logo.ContentLength > 1 * 1024 * 1024)//1 MB { this.ShowPopup(1, "Image Size must be less than 1MB"); return(View(agentModel)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "logo " + datet + ext.ToLower(); Agent_LogoPath = Path.Combine(Server.MapPath("~/Content/userupload/Agent"), myfilename); AC.AgentLogo = "/Content/userupload/Agent/" + myfilename; } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(agentModel)); } } if (AC.AgentOperationType.ToUpper() == "BUSINESS") { if (Pan_Certiticate != null) { var allowedExtensions = new[] { ".jpg", ".png", ".jpeg" }; var fileName = Path.GetFileName(Pan_Certiticate.FileName); String timeStamp = DateTime.Now.ToString(); var ext = Path.GetExtension(Pan_Certiticate.FileName); if (Pan_Certiticate.ContentLength > 1 * 1024 * 1024)//1 MB { this.ShowPopup(1, "Image Size must be less than 1MB"); return(View(agentModel)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "pan " + datet + ext.ToLower(); Pan_CertiticatePath = Path.Combine(Server.MapPath("~/Content/userupload/Agent"), myfilename); AC.AgentPanCertificate = "/Content/userupload/Agent/" + myfilename; } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(agentModel)); } } if (Registration_Certificate != null) { var allowedExtensions = new[] { ".jpg", ".png", ".jpeg" }; var fileName = Path.GetFileName(Registration_Certificate.FileName); String timeStamp = DateTime.Now.ToString(); var ext = Path.GetExtension(Registration_Certificate.FileName); if (Registration_Certificate.ContentLength > 1 * 1024 * 1024)//1 MB { this.ShowPopup(1, "Image Size must be less than 1MB"); return(View(agentModel)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "reg" + datet + ext.ToLower(); Registration_CertificatePath = Path.Combine(Server.MapPath("~/Content/userupload/Agent"), myfilename); AC.AgentRegistrationCertificate = "/Content/userupload/Agent/" + myfilename; //Registration_Certificate.SaveAs(path); } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(agentModel)); } } } CommonDbResponse dbresp = buss.ManageAgent(AC); if (dbresp.Code == 0) { if (AC.AgentOperationType.ToUpper() == "BUSINESS") { if (Pan_Certiticate != null) { Pan_Certiticate.SaveAs(Pan_CertiticatePath); } if (Registration_Certificate != null) { Registration_Certificate.SaveAs(Registration_CertificatePath); } } if (Agent_Logo != null) { Agent_Logo.SaveAs(Agent_LogoPath); } this.ShowPopup(0, dbresp.Message); return(RedirectToAction("Index", new { parent_id = agentModel.ParentID })); } agentModel.Msg = dbresp.Message; } this.ShowPopup(1, "Error " + agentModel.Msg); return(View(agentModel)); }
public void RemoveupdateValidation(AgentManagementModel AMM) { ModelState.Remove("Password"); ModelState.Remove("confirmPassword"); }