public ActionResult Add(CaseStudyManageModel model, HttpPostedFileBase docFile) { ViewBag.SchoolID = _sModel.SchoolID; if (model.CaseStudy.SchoolID == 0) { model.CaseStudy.SchoolID = _sModel.SchoolID; } var validData = true; if (docFile != null) { string fileResult = FileTypeCheck.IsValidFile(docFile, "File"); if (!fileResult.Equals("Success")) { ModelState.AddModelError("FileErr", fileResult); validData = false; } else { string file_result = SaveFile(docFile); model.CaseStudy.CaseStudyFilePath = FileUrl + "CaseStudy/" + file_result; if (file_result.Contains("Error")) { TempData["ErrMsg"] = file_result; return(View(model)); } } } else { ModelState.AddModelError("FileErr", "Select Case Study file"); validData = false; } if (ModelState.IsValid && validData) { model.CaseStudy.IsPublished = false; model.CaseStudy.TransDate = DateTime.Now; model.CaseStudy.UserID = User.Identity.Name; string result = objCaseStudy.SaveCaseStudy(model.CaseStudy); if (result.Contains("Success")) { objSite.AddAuditLog("utblCaseStudies", "New Case Study Added", IPAddressGetter.GetIPAddress(), User.Identity.Name); TempData["ErrMsg"] = result; return(RedirectToAction("index", "casestudy", new { Area = "Admin" })); } else { DeleteFile(model.CaseStudy.CaseStudyFilePath); TempData["ErrMsg"] = result; } } model.Components = objcomp.GetComponentList(""); model.SchoolList = ObjSch.GetSchoolList(""); return(View(model)); }
public ActionResult Edit(VideoSaveModel model, HttpPostedFileBase docFile) { utblVideo vid = new utblVideo(); vid = objVideo.GetVideoByID(model.Videos.VideoID); string PrvPath = vid.VideoFilePathDraft; string file_result = ""; var validData = true; if (docFile != null) { string fileResult = FileTypeCheck.IsValidFile(docFile, "Video"); if (!fileResult.Equals("Success")) { ModelState.AddModelError("FileErr", fileResult); validData = false; } else { file_result = SaveFile(docFile, model.Videos.VideoAlbumID); model.Videos.VideoFilePathDraft = FileUrl + "/Videos/" + file_result; if (file_result.Contains("Error")) { TempData["ErrMsg"] = file_result; return(View(model)); } } } if (ModelState.IsValid && validData) { //model.Videos.VideoAlbumID = model.VideoAlbum.VideoAlbumID; model.Videos.TransDate = DateTime.Now; model.Videos.UserID = User.Identity.Name; string result = objVideo.SaveVideo(model.Videos); if (result.Contains("Success")) { if (file_result != "") { DeleteFile(PrvPath); } objSite.AddAuditLog("utblVideos", "Videos Updated", IPAddressGetter.GetIPAddress(), User.Identity.Name); TempData["ErrMsg"] = result; return(RedirectToAction("index", "Video", new { Area = "Admin", AlbumID = model.Videos.VideoAlbumID })); } TempData["ErrMsg"] = result; } model.VideoAlbum = objVideoAlbum.GetVideoAlbumByID(model.Videos.VideoAlbumID); return(View(model)); }
public ActionResult EditBanner(SaveBanner model) { try { ViewBag.ActiveURL = "/Admin/bannerlist"; if (model.cropper.PhotoNormal != null) { bool isValidFile = FileTypeCheck.DataImage(model.cropper.PhotoNormal); //bool isValidThumb = FileTypeCheck.DataImage(model.cropper.PhotoThumb); if (!isValidFile) { TempData["ErrMsg"] = "Please Select A Valid Image File!"; return(View()); } Random rand = new Random(); string name = "Banner_" + DateTime.Now.ToString("yyyyMMdd") + "_" + rand.Next(50) + ".webp"; string normal_result = SaveImage(model.cropper.PhotoNormal, name); if (normal_result.Contains("Error")) { TempData["ErrMsg"] = "Please Select A Valid Image File!"; return(View()); } else { model.Banner.BannerPath = "/Uploads/Banner/" + normal_result; } } else { model.Banner.BannerPath = model.Banner.BannerPath; } if (ModelState.IsValid) { string jsonStr = JsonConvert.SerializeObject(model.Banner); TempData["ErrMsg"] = objAPI.PostRecordtoApI("configuration", "savebanner", jsonStr); return(RedirectToAction("BannerList", "Banner", new { Area = "Admin" })); } return(View(model)); } catch (AuthorizationException) { TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again"; return(RedirectToAction("Login", "Account", new { Area = "" })); } }
public ActionResult Add(DestinationSaveModel model) { try { Random rand = new Random(); string name = "Banner_" + DateTime.Now.ToString("yyyyMMdd") + "_" + rand.Next(50) + ".webp"; bool isValidFile = FileTypeCheck.DataImage(model.cropper.PhotoNormal); if (!isValidFile) { TempData["ErrMsg"] = "Please Select A Valid Image File!"; return(View(model)); } string normal_result = SaveImage(model.cropper.PhotoNormal, name); if (normal_result.Contains("Error")) { TempData["ErrMsg"] = normal_result; return(RedirectToAction("index", "destination", new { Area = "Admin" })); } else { model.Destination.DestinationImagePath = "/Uploads/Destinations/" + normal_result; } if (ModelState.IsValid) { string jsonStr = JsonConvert.SerializeObject(model.Destination); TempData["ErrMsg"] = objAPI.PostRecordtoApI("configuration", "savedestination", jsonStr); return(RedirectToAction("index", "destination", new { Area = "Admin" })); } model.CountryList = objAPI.GetAllRecords <CountryDD>("configuration", "CountriesList"); return(View(model)); } catch (AuthorizationException) { TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again"; return(RedirectToAction("Login", "Account", new { Area = "" })); } }
public ActionResult AddAgent(SaveAgent model) { try { ViewBag.ActiveURL = "/Admin/Agentlist"; if (!(model.cropper.PhotoNormal == null || model.cropper.PhotoNormal == "")) { Random rand = new Random(); string name = model.Agent.AgentName + DateTime.Now.ToString("yyyyMMdd") + "_" + rand.Next(50) + ".jpg"; bool isValidFile = FileTypeCheck.DataImage(model.cropper.PhotoNormal); string normal_result = SaveImage(model.cropper.PhotoNormal, name); if (normal_result.Contains("Error")) { TempData["ErrMsg"] = normal_result; return(RedirectToAction("BannerList", "Banner")); } else { model.Agent.AgentDocumentPath = FileUrl + "/AgentDocument/" + normal_result; } } if (ModelState.IsValid) { string jsonStr = JsonConvert.SerializeObject(model.Agent); TempData["ErrMsg"] = objAPI.PostRecordtoApI("AgentConfig", "saveagent", jsonStr); return(RedirectToAction("AgentList", "AgentConfig", new { Area = "Admin" })); } return(View(model)); } catch (AuthorizationException) { TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again"; return(RedirectToAction("Login", "Account", new { Area = "" })); } }
public ActionResult AddPackageOffer(SavePackageOffer model) { try { ViewBag.ActiveURL = "/Admin/packageofferlist"; Random rand = new Random(); string name = "OfferBanner_" + DateTime.Now.ToString("yyyyMMdd") + "_" + rand.Next(50) + ".webp"; bool isValidFile = FileTypeCheck.DataImage(model.cropper.PhotoNormal); if (!isValidFile) { TempData["ErrMsg"] = "Please Select A Valid Image File!"; return(View(model)); } string normal_result = SaveImage(model.cropper.PhotoNormal, name); if (normal_result.Contains("Error")) { TempData["ErrMsg"] = normal_result; return(RedirectToAction("AddPackageOffer", "package", new { Area = "Admin" })); } else { model.PackageOffer.OfferImagePath = "/Uploads/Offer/" + normal_result; } //if (ModelState.IsValid) //{ string jsonStr = JsonConvert.SerializeObject(model); TempData["ErrMsg"] = objAPI.PostRecordtoApI("packageconfig", "savepackageoffer", jsonStr); return(RedirectToAction("PackageOfferList", "package", new { Area = "Admin" })); //} //return View(model); } catch (AuthorizationException) { TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again"; return(RedirectToAction("Login", "Account", new { Area = "" })); } }