public ActionResult addUsers(SubDistributorModel SDM, string changepassword) { ViewBag.UserTypeList = ApplicationUtilities.SetDDLValue(LoadDropdownList("usertype"), SDM.UserType, "--Select User Type--"); ViewBag.UserStatusList = ApplicationUtilities.SetDDLValue(LoadDropdownList("status"), SDM.UserStatus, "--Select Status--"); ViewBag.UserIsPrimaryList = ApplicationUtilities.SetDDLValue(LoadDropdownList("isprimary") as Dictionary <string, string>, SDM.isPrimary, "--Is Primary--"); RemoveAgentValidation(SDM); RemoveContactPersonValidation(SDM); if (changepassword.ToUpper() != "ON") { ModelState.Remove("Password"); ModelState.Remove("ConfirmPassword"); } if (ModelState.IsValid) { if (string.IsNullOrEmpty(SDM.AgentID.DecryptParameter())) { this.ShowPopup(1, "Error. Please try again!"); return(View(SDM)); } if (!string.IsNullOrEmpty(SDM.UserId)) { if (string.IsNullOrEmpty(SDM.UserId.DecryptParameter())) { this.ShowPopup(1, "Error. Please try again!"); return(View(SDM)); } } SDM.UserId = SDM.UserId.DecryptParameter(); SDM.AgentID = SDM.AgentID.DecryptParameter(); string[] usertype_id = SDM.UserType.Split('|'); SDM.UserType = usertype_id[1]; SDM.UserTypeId = usertype_id[0]; SubDistributorCommon SDC = SDM.MapObject <SubDistributorCommon>(); CommonDbResponse dbresp = ISD.ManageUser(SDC, changepassword); if (dbresp.Code == 0) { this.ShowPopup(0, dbresp.Message); return(RedirectToAction("ViewUser", new { agentid = SDM.AgentID.EncryptParameter() })); } } this.ShowPopup(1, "Save unsuccessful.Please try again!"); return(View(SDM)); }
public ActionResult Manage(SubDistributorModel SDM, HttpPostedFileBase Agent_Logo, HttpPostedFileBase Pan_Certiticate, HttpPostedFileBase Registration_Certificate) { ViewBag.PermanentCountryList = ApplicationUtilities.SetDDLValue(LoadDropdownList("country"), SDM.PermanentCountry, "--Permanent Country--"); ViewBag.PermanentProvienceList = ApplicationUtilities.SetDDLValue(LoadDropdownList("province", SDM.PermanentCountry), SDM.PermanentProvince, "--Permanent Provience--"); ViewBag.PermanentDistrictList = ApplicationUtilities.SetDDLValue(LoadDropdownList("districtList", SDM.PermanentProvince) as Dictionary <string, string>, SDM.PermanentDistrict, "--Permanent District--"); ViewBag.PermanentVDC_MuncipilityList = ApplicationUtilities.SetDDLValue(LoadDropdownList("vdc_muncipality", SDM.PermanentDistrict), SDM.PermanentVDC_Muncipality, "--Permanent VDC Muncipality--"); ViewBag.TemporarytCountryList = ApplicationUtilities.SetDDLValue(LoadDropdownList("country"), SDM.TemporaryCountry, "--Temporary Country--"); ViewBag.TemporaryProvienceList = ApplicationUtilities.SetDDLValue(LoadDropdownList("province", SDM.TemporaryCountry), SDM.TemporaryProvince, "--Temporary Provience--"); ViewBag.TemporaryDistrictList = ApplicationUtilities.SetDDLValue(LoadDropdownList("districtList", SDM.TemporaryProvince), SDM.TemporaryDistrict, "--Temporary District--"); ViewBag.TemporaryVDC_MuncipilityList = ApplicationUtilities.SetDDLValue(LoadDropdownList("vdc_muncipality", SDM.TemporaryDistrict), SDM.TemporaryVDC_Muncipality, "--Temporary VDC Muncipality--"); ViewBag.GenderList = ApplicationUtilities.SetDDLValue(LoadDropdownList("gender"), SDM.Gender, "--Select Gender--"); ViewBag.OccupationList = ApplicationUtilities.SetDDLValue(LoadDropdownList("occupation"), SDM.Occupation, "--Select Occupation--"); ViewBag.Nationalitylist = ApplicationUtilities.SetDDLValue(LoadDropdownList("nationality"), SDM.Nationality, "--Select Nationality--"); ViewBag.DoctypeList = ApplicationUtilities.SetDDLValue(LoadDropdownList("doctype"), SDM.Nationality, "--Select Document Type--"); ViewBag.IssueDistrictList = ApplicationUtilities.SetDDLValue(LoadDropdownList("issuedistrict"), SDM.Nationality, "--Select District--"); if (!string.IsNullOrEmpty(SDM.AgentID)) { RemoveUserValidation(SDM); } if (SDM.AgentOperationType.ToUpper() == "INDIVIDUAL") { RemoveContactPersonValidation(SDM); } if (ModelState.IsValid) { SubDistributorCommon SDC = SDM.MapObject <SubDistributorCommon>(); if (!string.IsNullOrEmpty(SDC.AgentID)) { if (string.IsNullOrEmpty(SDC.AgentID.DecryptParameter())) { return(View("Manage", SDM)); } SDC.AgentID = SDC.AgentID.DecryptParameter(); } if (!string.IsNullOrEmpty(SDC.UserId)) { if (string.IsNullOrEmpty(SDC.UserId.DecryptParameter())) { return(View("Manage", SDM)); } SDC.UserId = SDC.UserId.DecryptParameter(); } if (!string.IsNullOrEmpty(SDC.ParentId)) { SDC.ParentId = SDC.ParentId.DecryptParameter(); } SDC.ActionUser = Session["username"].ToString(); SDC.IpAddress = ApplicationUtilities.GetIP(); 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(SDM)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "logo " + datet + "." + Pan_Certiticate.FileName; var path = Path.Combine(Server.MapPath("~/Content/assets/images/Sub_Distributor"), myfilename); SDC.AgentPanCertificate = myfilename; Pan_Certiticate.SaveAs(path); } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(SDM)); } } 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(SDM)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "logo " + datet + "." + Registration_Certificate.FileName; var path = Path.Combine(Server.MapPath("~/Content/assets/images/Sub_Distributor"), myfilename); SDC.AgentRegistrationCertificate = myfilename; Registration_Certificate.SaveAs(path); } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(SDM)); } } if (Agent_Logo != null) { 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(SDM)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "logo " + datet + "." + Agent_Logo.FileName; var path = Path.Combine(Server.MapPath("~/Content/assets/images/Sub_Distributor"), myfilename); SDC.AgentLogo = myfilename; Agent_Logo.SaveAs(path); } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(SDM)); } } var dbresp = ISD.Manage(SDC); if (dbresp.Code == 0) { this.ShowPopup(0, dbresp.Message); return(RedirectToAction("Index", new{ DistId = SDM.ParentId })); } SDM.Msg = dbresp.Message; } this.ShowPopup(1, "Error " + SDM.Msg); return(View(SDM)); }