public ActionResult ManageMerchant(MerchantModel merchantModel, HttpPostedFileBase Merchant_Logo, HttpPostedFileBase Pan_Certiticate, HttpPostedFileBase Registration_Certificate, string changepassword) { var Merchant_LogoPath = ""; var Pan_CertiticatePath = ""; var Registration_CertificatePath = ""; LoadDropDownList(merchantModel); if (!string.IsNullOrEmpty(merchantModel.MerchantID.DecryptParameter())) { ModelState.Remove("UserName"); ModelState.Remove("Password"); ModelState.Remove("ConfirmPassword"); ModelState.Remove("FullName"); ModelState.Remove("UserMobileNumber"); ModelState.Remove("UserEmail"); ModelState.Remove("FirstName"); ModelState.Remove("LastName"); if (string.IsNullOrEmpty(changepassword)) { ModelState.Remove("UserName"); ModelState.Remove("Password"); ModelState.Remove("ConfirmPassword"); } } if (ModelState.IsValid) { MerchantCommon merchantCommon = new MerchantCommon(); merchantCommon = merchantModel.MapObject <MerchantCommon>(); if (!string.IsNullOrEmpty(merchantCommon.MerchantID)) { if (string.IsNullOrEmpty(merchantCommon.MerchantID.DecryptParameter())) { return(View(merchantModel)); } if (string.IsNullOrEmpty(changepassword)) { merchantCommon.Password = ""; merchantCommon.ConfirmPassword = ""; merchantCommon.MerchantEmail = ""; merchantCommon.MerchantMobileNumber = ""; } merchantCommon.MerchantID = merchantCommon.MerchantID.DecryptParameter(); merchantCommon.UserID = merchantCommon.UserID.DecryptParameter(); } if (!string.IsNullOrEmpty(merchantCommon.ParentID)) { if (string.IsNullOrEmpty(merchantCommon.ParentID.DecryptParameter())) { return(View(merchantModel)); } merchantCommon.ParentID = merchantCommon.ParentID.DecryptParameter(); } merchantCommon.ActionUser = ApplicationUtilities.GetSessionValue("UserName").ToString(); merchantCommon.IpAddress = ApplicationUtilities.GetIP(); if (Merchant_Logo != null) { var allowedExtensions = new[] { ".jpg", ".png", ".jpeg" }; var fileName = Path.GetFileName(Merchant_Logo.FileName); String timeStamp = DateTime.Now.ToString(); var ext = Path.GetExtension(Merchant_Logo.FileName); if (Merchant_Logo.ContentLength > 1 * 1024 * 1024)//1 MB { this.ShowPopup(1, "Image Size must be less than 1MB"); return(View(merchantModel)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "logo " + datet + "." + Merchant_Logo.FileName; Merchant_LogoPath = Path.Combine(Server.MapPath("~/Content/userupload/merchant"), myfilename); merchantCommon.MerchantLogo = "/Content/userupload/merchant/" + myfilename; } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(merchantModel)); } } 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(merchantModel)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "pan " + datet + "." + Pan_Certiticate.FileName; Pan_CertiticatePath = Path.Combine(Server.MapPath("~/Content/userupload/merchant"), myfilename); merchantCommon.MerchantPanCertificate = "/Content/userupload/merchant/" + myfilename; } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(merchantModel)); } } 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(merchantModel)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "reg " + datet + "." + Registration_Certificate.FileName; Registration_CertificatePath = Path.Combine(Server.MapPath("~/Content/userupload/merchant"), myfilename); merchantCommon.MerchantRegistrationCertificate = "/Content/userupload/merchant/" + myfilename; //Registration_Certificate.SaveAs(path); } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(merchantModel)); } } CommonDbResponse dbresp = _merchant.ManageMerchant(merchantCommon); if (dbresp.Code == 0) { if (Pan_Certiticate != null) { Pan_Certiticate.SaveAs(Pan_CertiticatePath); } if (Registration_Certificate != null) { Registration_Certificate.SaveAs(Registration_CertificatePath); } if (Merchant_Logo != null) { Merchant_Logo.SaveAs(Merchant_LogoPath); } string userId = dbresp.Extra1; string agentId = dbresp.Extra2; string AgentCode = dbresp.Extra3; QRCoder.QRCodeGenerator qrGenerator = new QRCodeGenerator(); var encData = AgentCode.EncryptParameterForQr(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(encData, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeImage = qrCode.GetGraphic(20); string ImageUrl = ""; using (MemoryStream stream = new MemoryStream()) { qrCodeImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png); byte[] byteImage = stream.ToArray(); ImageUrl = string.Format(Convert.ToBase64String(byteImage)); } string qrFilePath = Server.MapPath("~/Content/userupload/Merchant/"); string qrImageName = "qrImage" + "_" + userId + "_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("-", "_").Replace(" ", "_").Replace(":", "_") + ".png"; qrCodeImage.Save(qrFilePath + qrImageName, ImageFormat.Png); CommonDbResponse qrInsert = _merchant.AddCardQr(userId, agentId, ImageUrl, "/Content/userupload/Merchant/" + qrImageName); this.ShowPopup(0, dbresp.Message); return(RedirectToAction("Index")); } merchantModel.Msg = dbresp.Message; } this.ShowPopup(1, "Error " + merchantModel.Msg); return(View(merchantModel)); }
public ActionResult ManageMerchant(MerchantModel merchantModel, HttpPostedFileBase Merchant_Logo, HttpPostedFileBase Pan_Certiticate, HttpPostedFileBase Registration_Certificate, string changepassword) { var Merchant_LogoPath = ""; var Pan_CertiticatePath = ""; var Registration_CertificatePath = ""; LoadDropDownList(merchantModel); if (!string.IsNullOrEmpty(merchantModel.MerchantID.DecryptParameter())) { ModelState.Remove("UserName"); if (string.IsNullOrEmpty(changepassword)) { ModelState.Remove("Password"); ModelState.Remove("ConfirmPassword"); } } if (ModelState.IsValid) { MerchantCommon merchantCommon = new MerchantCommon(); merchantCommon = merchantModel.MapObject <MerchantCommon>(); if (!string.IsNullOrEmpty(merchantCommon.MerchantID)) { if (string.IsNullOrEmpty(merchantCommon.MerchantID.DecryptParameter())) { return(View(merchantModel)); } if (string.IsNullOrEmpty(changepassword)) { merchantCommon.Password = ""; merchantCommon.ConfirmPassword = ""; merchantCommon.MerchantEmail = ""; merchantCommon.MerchantMobileNumber = ""; } merchantCommon.MerchantID = merchantCommon.MerchantID.DecryptParameter(); merchantCommon.UserID = merchantCommon.UserID.DecryptParameter(); } if (!string.IsNullOrEmpty(merchantCommon.ParentID)) { if (string.IsNullOrEmpty(merchantCommon.ParentID.DecryptParameter())) { return(View(merchantModel)); } merchantCommon.ParentID = merchantCommon.ParentID.DecryptParameter(); } merchantCommon.ActionUser = ApplicationUtilities.GetSessionValue("UserName").ToString(); merchantCommon.IpAddress = ApplicationUtilities.GetIP(); if (Merchant_Logo != null) { var allowedExtensions = new[] { ".jpg", ".png", ".jpeg" }; var fileName = Path.GetFileName(Merchant_Logo.FileName); String timeStamp = DateTime.Now.ToString(); var ext = Path.GetExtension(Merchant_Logo.FileName); if (Merchant_Logo.ContentLength > 1 * 1024 * 1024)//1 MB { this.ShowPopup(1, "Image Size must be less than 1MB"); return(View(merchantModel)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "logo " + datet + "." + Merchant_Logo.FileName; Merchant_LogoPath = Path.Combine(Server.MapPath("~/Content/userupload/merchant"), myfilename); merchantCommon.MerchantLogo = "/Content/userupload/merchant/" + myfilename; } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(merchantModel)); } } 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(merchantModel)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "pan " + datet + "." + Pan_Certiticate.FileName; Pan_CertiticatePath = Path.Combine(Server.MapPath("~/Content/userupload/merchant"), myfilename); merchantCommon.MerchantPanCertificate = "/Content/userupload/merchant/" + myfilename; } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(merchantModel)); } } 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(merchantModel)); } if (allowedExtensions.Contains(ext.ToLower())) { string datet = DateTime.Now.ToString().Replace('/', ' ').Replace(':', ' '); string myfilename = "reg " + datet + "." + Registration_Certificate.FileName; Registration_CertificatePath = Path.Combine(Server.MapPath("~/Content/userupload/merchant"), myfilename); merchantCommon.MerchantRegistrationCertificate = "/Content/userupload/merchant/" + myfilename; //Registration_Certificate.SaveAs(path); } else { this.ShowPopup(1, "File Must be .jpg,.png,.jpeg"); return(View(merchantModel)); } } CommonDbResponse dbresp = _merchant.ManageMerchant(merchantCommon); if (dbresp.Code == 0) { if (Pan_Certiticate != null) { Pan_Certiticate.SaveAs(Pan_CertiticatePath); } if (Registration_Certificate != null) { Registration_Certificate.SaveAs(Registration_CertificatePath); } if (Merchant_Logo != null) { Merchant_Logo.SaveAs(Merchant_LogoPath); } this.ShowPopup(0, dbresp.Message); return(RedirectToAction("Index")); } merchantModel.Msg = dbresp.Message; } this.ShowPopup(1, "Error " + merchantModel.Msg); return(View(merchantModel)); }