public ActionResult ManageDistributorUsers(DistributorManagementModel DMM) { //RemoveAgentValidation(dcommon); //RemoveContactPersonValidation(dcommon); LoadDropDownList(DMM); RemoveAgentValidation(DMM); DistributorManagementCommon DMC = new DistributorManagementCommon(); DMC = DMM.MapObject <DistributorManagementCommon>(); if (!string.IsNullOrEmpty(DMC.UserID)) { ModelState.Remove("UserName"); ModelState.Remove("Password"); ModelState.Remove("ConfirmPassword"); } if (ModelState.IsValid) { if (!string.IsNullOrEmpty(DMC.UserID)) { DMC.UserID = DMC.UserID.DecryptParameter(); } if (!string.IsNullOrEmpty(DMC.AgentID)) { DMC.AgentID = DMC.AgentID.DecryptParameter(); } DMC.ActionUser = ApplicationUtilities.GetSessionValue("username").ToString(); DMC.IpAddress = ApplicationUtilities.GetIP(); CommonDbResponse dbresp = buss.ManageUser(DMC); if (dbresp.Code == shared.Models.ResponseCode.Success) { this.ShowPopup(0, "Save Succesfully"); return(RedirectToAction("ViewDistributorUser", new { DistId = DMC.AgentID.EncryptParameter() })); } } this.ShowPopup(1, "Save unsuccessful.Please try again!"); return(View(DMM)); }
public ActionResult ManageDistributor(DistributorManagementModel DistModel, 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(DistModel); if (!string.IsNullOrEmpty(DistModel.AgentID.DecryptParameter())) { ModelState.Remove("userName"); RemoveupdateValidation(DistModel); } if (DistModel.AgentOperationType.ToUpper() != "BUSINESS") { DistModel.AgentEmail = DistModel.UserEmail; DistModel.AgentMobileNumber = DistModel.UserMobileNumber; RemoveBusinessValidation(DistModel); } if (ModelState.IsValid) { DistributorManagementCommon DMC = new DistributorManagementCommon(); DMC = DistModel.MapObject <DistributorManagementCommon>(); if (!string.IsNullOrEmpty(DMC.AgentID)) { if (string.IsNullOrEmpty(DMC.AgentID.DecryptParameter())) { return(View(DistModel)); } if (string.IsNullOrEmpty(changepassword)) { DMC.Password = ""; DMC.ConfirmPassword = ""; } DMC.AgentID = DMC.AgentID.DecryptParameter(); DMC.UserID = DMC.UserID.DecryptParameter(); } if (!string.IsNullOrEmpty(DMC.ParentID)) { if (string.IsNullOrEmpty(DMC.ParentID.DecryptParameter())) { return(View(DistModel)); } DMC.ParentID = DMC.ParentID.DecryptParameter(); } DMC.ActionUser = ApplicationUtilities.GetSessionValue("UserName").ToString(); DMC.IpAddress = ApplicationUtilities.GetIP(); 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(DistModel)); } 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/Distributor"), myfilename); DMC.AgentLogo = "/Content/userupload/Distributor/" + myfilename; } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(DistModel)); } } if (DMC.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(DistModel)); } 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/Distributor"), myfilename); DMC.AgentPanCertificate = "/Content/userupload/Distributor/" + myfilename; } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(DistModel)); } } 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(DistModel)); } 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/Distributor"), myfilename); DMC.AgentRegistrationCertificate = "/Content/userupload/Distributor/" + myfilename; //Registration_Certificate.SaveAs(path); } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(DistModel)); } } } CommonDbResponse dbresp = buss.ManageDistributor(DMC); if (dbresp.Code == 0) { if (DMC.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")); } DistModel.Msg = dbresp.Message; } this.ShowPopup(1, "Error " + DistModel.Msg); return(View(DistModel)); }