public ActionResult SavePromotion(FormCollection fc, HttpPostedFileBase[] file, HttpPostedFileBase[] file1, HttpPostedFileBase[] file2, HttpPostedFileBase[] file3, string chkvalue) { PromotionLibrary _objPromotion = new PromotionLibrary(); string result = fc["AllData"]; string result1 = fc["AllData1"]; string result2 = fc["AllData2"]; _objPromotion.PName = fc["PName"]; _objPromotion.PEmailId = fc["PEmailId"]; _objPromotion.PContactNumber = fc["PContactNumber"]; if (file[0] != null) { _objPromotion.PReference = file[0].FileName; file[0].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objPromotion.PReference)); } if (file[1] != null) { _objPromotion.PCompanyProfile = file[1].FileName; file[1].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objPromotion.PCompanyProfile)); } // _objPromotion.IndustriesID = Convert.ToInt32(fc["IndustriesID"]); _objPromotion.Status = "A"; _objPromotion.IsActive = false; db.PromotionLibraries.Add(_objPromotion); db.SaveChanges(); var lastID = _objPromotion.PromotionLibraryID; string[] abc = result.Split('~'); PromotionProductList _objproduct = new PromotionProductList(); for (int i = 0; i < abc.Count() - 1; i++) { _objproduct.PromotionLibraryID = Convert.ToInt32(lastID); _objproduct.ProductName = abc[i].Split(',')[0]; _objproduct.ProductIndustry = abc[i].Split(',')[1]; if (file1[i] != null) { _objproduct.ProductBrochure = file1[i].FileName; file1[i].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objproduct.ProductBrochure)); } if (file1[i + 1] != null) { _objproduct.URSFormat = file1[i + 1].FileName; file1[i + 1].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objproduct.URSFormat)); } db.PromotionProductLists.Add(_objproduct); db.SaveChanges(); } PromotionCertificate _objprmCertificate = new PromotionCertificate(); string[] mno = result1.Split('~'); for (int i = 0; i < mno.Count() - 1; i++) { _objprmCertificate.PromotionLibraryID = Convert.ToInt32(lastID); _objprmCertificate.CertificateName = mno[i]; if (file2[i] != null) _objprmCertificate.CertificateAttachment = file2[i].FileName; file2[i].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objprmCertificate.CertificateAttachment)); } db.PromotionCertificates.Add(_objprmCertificate); db.SaveChanges(); PromotionOtherDocument _objprmOtherDocument = new PromotionOtherDocument(); string[] xyz = result2.Split('~'); for (int i = 0; i < xyz.Count() - 1; i++) { _objprmOtherDocument.PromotionLibraryID = Convert.ToInt32(lastID); _objprmOtherDocument.OtherDocumentName = xyz[i]; if (file3[i] != null) _objprmOtherDocument.DocumentAttachment = file3[i].FileName; file3[i].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objprmOtherDocument.DocumentAttachment)); } db.PromotionOtherDocuments.Add(_objprmOtherDocument); db.SaveChanges(); string[] ch = chkvalue.Split(','); PromotionIndustry objProIndustry = new PromotionIndustry(); for (int i = 0; i < ch.Count(); i++) { objProIndustry.PromotionLibraryID = Convert.ToInt32(lastID); objProIndustry.IndustriesID = Convert.ToInt32(ch[i]); db.PromotionIndustries.Add(objProIndustry); db.SaveChanges(); } TempData["Data"] = "Thanks for sharing your material with i4i.<br/> Your request has been received and is subjected to approval from i4i."; TempData["vColor"] = "green"; return RedirectToAction("PromotionLibraryForm"); }
public ActionResult SavePromotion(FormCollection fc, HttpPostedFileBase[] file, HttpPostedFileBase[] file1, HttpPostedFileBase[] file2, HttpPostedFileBase[] file3, string chkvalue) { PromotionLibrary _objPromotion = new PromotionLibrary(); string result = fc["AllData"]; string result1 = fc["AllData1"]; string result2 = fc["AllData2"]; _objPromotion.PName = fc["PName"]; _objPromotion.PEmailId = fc["PEmailId"]; _objPromotion.PContactNumber = fc["PContactNumber"]; if (file[0] != null) { _objPromotion.PReference = file[0].FileName; file[0].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objPromotion.PReference)); } if (file[1] != null) { _objPromotion.PCompanyProfile = file[1].FileName; file[1].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objPromotion.PCompanyProfile)); } // _objPromotion.IndustriesID = Convert.ToInt32(fc["IndustriesID"]); _objPromotion.Status = "A"; _objPromotion.IsActive = false; db.PromotionLibraries.Add(_objPromotion); db.SaveChanges(); var lastID = _objPromotion.PromotionLibraryID; string[] abc = result.Split('~'); PromotionProductList _objproduct = new PromotionProductList(); for (int i = 0; i < abc.Count() - 1; i++) { _objproduct.PromotionLibraryID = Convert.ToInt32(lastID); _objproduct.ProductName = abc[i].Split(',')[0]; _objproduct.ProductIndustry = abc[i].Split(',')[1]; if (file1[i] != null) { _objproduct.ProductBrochure = file1[i].FileName; file1[i].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objproduct.ProductBrochure)); } if (file1[i + 1] != null) { _objproduct.URSFormat = file1[i + 1].FileName; file1[i + 1].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objproduct.URSFormat)); } db.PromotionProductLists.Add(_objproduct); db.SaveChanges(); } PromotionCertificate _objprmCertificate = new PromotionCertificate(); string[] mno = result1.Split('~'); for (int i = 0; i < mno.Count() - 1; i++) { _objprmCertificate.PromotionLibraryID = Convert.ToInt32(lastID); _objprmCertificate.CertificateName = mno[i]; if (file2[i] != null) { _objprmCertificate.CertificateAttachment = file2[i].FileName; } file2[i].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objprmCertificate.CertificateAttachment)); } db.PromotionCertificates.Add(_objprmCertificate); db.SaveChanges(); PromotionOtherDocument _objprmOtherDocument = new PromotionOtherDocument(); string[] xyz = result2.Split('~'); for (int i = 0; i < xyz.Count() - 1; i++) { _objprmOtherDocument.PromotionLibraryID = Convert.ToInt32(lastID); _objprmOtherDocument.OtherDocumentName = xyz[i]; if (file3[i] != null) { _objprmOtherDocument.DocumentAttachment = file3[i].FileName; } file3[i].SaveAs(Server.MapPath("~/Content/PromotionFile/" + _objprmOtherDocument.DocumentAttachment)); } db.PromotionOtherDocuments.Add(_objprmOtherDocument); db.SaveChanges(); string[] ch = chkvalue.Split(','); PromotionIndustry objProIndustry = new PromotionIndustry(); for (int i = 0; i < ch.Count(); i++) { objProIndustry.PromotionLibraryID = Convert.ToInt32(lastID); objProIndustry.IndustriesID = Convert.ToInt32(ch[i]); db.PromotionIndustries.Add(objProIndustry); db.SaveChanges(); } TempData["Data"] = "Thanks for sharing your material with i4i.<br/> Your request has been received and is subjected to approval from i4i."; TempData["vColor"] = "green"; return(RedirectToAction("PromotionLibraryForm")); }