public ActionResult UpdateSlide(int Manual_Slide_ID, string Manual_Slide_Header, int Manual_Slide_SortOrder, int Manual_Slide_Active) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.manualManagement manualManager = new hypster_tv_DAL.manualManagement(); hypster_tv_DAL.Manual_Slide slide = new hypster_tv_DAL.Manual_Slide(); slide.Manual_Slide_ID = Manual_Slide_ID; slide.Manual_Slide_Header = Manual_Slide_Header; slide.Manual_Slide_SortOrder = Manual_Slide_SortOrder; slide.Manual_Slide_Active = Manual_Slide_Active; manualManager.UpdateSlide(slide); return(RedirectPermanent("/WebsiteManagement/manageManuals")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult AddNewSlide(int Manual_ID, string Slide_Header, HttpPostedFileBase Slide_Image, int Slide_SortOrder) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.manualManagement manualManager = new hypster_tv_DAL.manualManagement(); hypster_tv_DAL.Manual currManual = new hypster_tv_DAL.Manual(); currManual = manualManager.GetManualByID(Manual_ID); hypster_tv_DAL.Manual_Slide slide = new hypster_tv_DAL.Manual_Slide(); slide.Manual_Slide_Manual_ID = Manual_ID; slide.Manual_Slide_Header = Slide_Header; string img_name_guid = Guid.NewGuid().ToString(); if (Slide_Image.FileName != null && Slide_Image.FileName != "") { System.IO.DirectoryInfo dirInf = new System.IO.DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["ManualsStorage_Path"] + "\\" + currManual.Manual_Guid); if (dirInf.Exists == false) { dirInf.Create(); } var extension = System.IO.Path.GetExtension(Slide_Image.FileName); string tmp_image_path = System.Configuration.ConfigurationManager.AppSettings["ManualsStorage_Path"] + "\\" + currManual.Manual_Guid + "\\TMP_" + img_name_guid + extension; string perm_image_path = System.Configuration.ConfigurationManager.AppSettings["ManualsStorage_Path"] + "\\" + currManual.Manual_Guid + "\\" + img_name_guid + extension; Slide_Image.SaveAs(tmp_image_path); hypster_tv_DAL.Image_Resize_Manager imageResizer = new hypster_tv_DAL.Image_Resize_Manager(); imageResizer.Resize_Image(tmp_image_path, 1024, -1, System.Drawing.Imaging.ImageFormat.Jpeg, perm_image_path, 70L); System.IO.FileInfo file_del = new System.IO.FileInfo(tmp_image_path); file_del.Delete(); //IMAGE slide.Manual_Slide_Image = img_name_guid + extension; } slide.Manual_Slide_Date = DateTime.Now; slide.Manual_Slide_SortOrder = Slide_SortOrder; slide.Manual_Slide_Active = 1; manualManager.AddNewManualSlide(slide); return(RedirectPermanent("/WebsiteManagement/manageManuals")); } else { return(RedirectPermanent("/home/")); } }