public ActionResult Create(int Page_ID, string Gallery_Name)
        {
            if (ModelState.IsValid)
            {
                Gallery gal = new Gallery();
                gal.Gallery_Name = Gallery_Name;
                gal.Date_Added   = DateTime.Now;
                gal.Added_By     = User.Identity.Name.ToString();///TODO: auth
                gal.Archived     = false;
                db.Galleries.Add(gal);
                db.SaveChanges();

                PageGalleryAssign galAss = new PageGalleryAssign();
                galAss.Gallery    = gal;
                galAss.Page_ID    = Page_ID;
                galAss.Date_Added = DateTime.Now;
                galAss.Added_By   = User.Identity.Name.ToString();///TODO: auth
                galAss.Archived   = false;
                db.PageGalleryAssigns.Add(galAss);

                db.SaveChanges();
                return(RedirectToAction("Edit", new { Page_ID = Page_ID, Gallery_ID = gal.Gallery_ID }));
            }
            else
            {
                ModelState.AddModelError("", "Error. Invalid Model State. Please try again.");
                GalleryCreateViewModel viewMod = new GalleryCreateViewModel(Page_ID);
                viewMod.Gallery_Name = Gallery_Name;
                return(View(viewMod));
            }
        }
        public ActionResult Create(string Gallery_Name, string Details, int Page_ID)
        {
            //if (ModelState.IsValid)
            //{
            VideoGallery videogallery = new VideoGallery();

            videogallery.Gallery_Name = Gallery_Name;
            videogallery.Details      = Details;
            videogallery.Date_Added   = DateTime.Now;
            videogallery.Added_By     = User.Identity.Name.ToString();///TODO auth
            videogallery.Archived     = false;
            db.VideoGalleries.Add(videogallery);
            db.SaveChanges();

            PageVideoGalleryAssign vidGalAssign = new PageVideoGalleryAssign();

            vidGalAssign.Page_ID      = Page_ID;
            vidGalAssign.VideoGallery = videogallery;
            db.PageVideoGalleryAssigns.Add(vidGalAssign);
            db.SaveChanges();

            return(RedirectToAction("Edit", new { Page_ID = Page_ID, Video_Gallery_ID = videogallery.Video_Gallery_ID }));
            //}
            //else
            //{
            //    VideoGalleryCreateViewModel vidGalViewMod = new VideoGalleryCreateViewModel();
            //    vidGalViewMod.Gallery_Name = Gallery_Name;
            //    vidGalViewMod.Details = Details;
            //    vidGalViewMod.Page_ID = Page_ID;
            //    ModelState.AddModelError("", "Invalid Mode");
            //    return View(vidGalViewMod);
            //}
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "Video_ID,File_Path,Thumb_Path,Date_Added,Added_By,Date_Archive,Archive_By,Archived,Video_Gallery_ID,Title_Text,Caption")] Video video)
        {
            if (ModelState.IsValid)
            {
                db.Videos.Add(video);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Video_Gallery_ID = new SelectList(db.VideoGalleries, "Video_Gallery_ID", "Gallery_Name", video.Video_Gallery_ID);
            return(View(video));
        }
        public ActionResult Create(string Title_Text, string Description, int Page_ID)
        {
            string         libName      = Title_Text.Replace(" ", "");
            List <Library> existingLibs = (List <Library>)(from l in db.Libraries where l.Library_Name == libName select l).ToList();

            if (!(existingLibs.Count() > 0))
            {
                Library library = new Library();
                library.Title_Text   = Title_Text;
                library.Library_Name = libName;
                library.Description  = Description;
                library.Date_Added   = DateTime.Now;
                library.Added_By     = User.Identity.Name.ToString();///TODO: auth needed
                library.Archived     = false;
                db.Libraries.Add(library);
                db.SaveChanges();

                PageLibraryAssign libAss = new PageLibraryAssign();
                libAss.Library = library;
                libAss.Page_ID = Page_ID;
                db.PageLibraryAssigns.Add(libAss);
                db.SaveChanges();

                return(RedirectToAction("Edit", new { Page_ID = Page_ID, Library_ID = library.Library_ID }));
            }
            else
            {
                ModelState.AddModelError("", "A Library with the name '" + Title_Text + "' already exists");
                LibraryCreateViewModel libMod = new LibraryCreateViewModel();
                libMod.Page_ID     = Page_ID;
                libMod.Description = Description;
                libMod.Title_Text  = Title_Text;
                return(View(libMod));
            }
        }
Beispiel #5
0
        public ActionResult Create(string Name, int Page_ID)
        {
            QuickLinkList newList = new QuickLinkList();

            newList.Name         = Name;
            newList.Archived     = false;
            newList.Date_Created = DateTime.Now;
            newList.Created_By   = User.Identity.Name;
            db.QuickLinkLists.Add(newList);

            PageQuickLinkListsAssign qlAss = new PageQuickLinkListsAssign();

            qlAss.Link_List_ID = newList.Link_List_ID;
            qlAss.Page_ID      = Page_ID;
            qlAss.Date_Added   = DateTime.Now;
            qlAss.Added_By     = User.Identity.Name;
            qlAss.Archived     = false;
            db.PageQuickLinkListsAssigns.Add(qlAss);

            db.SaveChanges();

            return(RedirectToAction("Edit", new { Link_List_ID = newList.Link_List_ID, Page_ID = Page_ID }));
        }
Beispiel #6
0
        public ActionResult Create(string Calender_Name, int Page_ID, bool?Return_Home)
        {
            if (Return_Home != null)
            {
                ViewBag.Return_Home = true;
                Page page = db.Pages.Find(Page_ID);
                ViewBag.Page_Url = page.URL;
            }
            if (db.Calenders.Where(x => x.Calender_Name == Calender_Name).Count() > 0)
            {
                CalenderCreateViewModel calViewMod = new CalenderCreateViewModel(Page_ID);
                calViewMod.Calender_Name = Calender_Name;
                ModelState.AddModelError("", "A Calender with the name '" + Calender_Name + "' alredy exists.");
                return(View(calViewMod));
            }
            else
            {
                Calender cal = new Calender();
                cal.Calender_Name = Calender_Name;
                cal.Date_Added    = DateTime.Now;
                cal.Added_By      = User.Identity.Name.ToString();///TODO: auth
                cal.Archived      = false;
                db.Calenders.Add(cal);
                db.SaveChanges();

                PageCalenderAssign callAss = new PageCalenderAssign();
                callAss.Page_ID    = Page_ID;
                callAss.Calender   = cal;
                callAss.Archived   = false;
                callAss.Date_Added = DateTime.Now;
                callAss.Added_By   = User.Identity.Name.ToString();///TODO: auth
                db.PageCalenderAssigns.Add(callAss);
                db.SaveChanges();

                return(RedirectToAction("Edit", new { Page_ID = Page_ID, Calender_ID = cal.Calender_ID, Return_Home = Return_Home }));
            }
        }
        public ActionResult Create([Bind(Include = "Collection_Title,Collection_Description,Display_Mode_ID,Page_ID")] CollectionCreateViewModel collectionViewMod, bool?Return_Home)
        {
            Collection collection = new Collection();

            collection.Collection_Description = collectionViewMod.Collection_Description;
            collection.Collection_Title       = collectionViewMod.Collection_Title;
            collection.Display_Mode_ID        = collectionViewMod.Display_Mode_ID;
            collection.Archived = false;
            db.Collections.Add(collection);
            db.SaveChanges();

            PageCollectionAssign ass = new PageCollectionAssign();

            ass.Collection  = collection;
            ass.Page_ID     = collectionViewMod.Page_ID;
            ass.Archived    = false;
            ass.Date_Added  = DateTime.Now;
            ass.Added_By    = User.Identity.Name.ToString();
            ass.Sequence_No = 9999;
            db.PageCollectionAssigns.Add(ass);
            db.SaveChanges();

            return(RedirectToAction("Edit", new { Collection_ID = collection.Collection_ID, Page_ID = collectionViewMod.Page_ID }));
        }
Beispiel #8
0
        public ActionResult Create(string Header, string Summary, int Collection_ID, int Page_ID)
        {
            string pathRoot   = "~/images/posts/thumbs/";
            string dbPathRoot = "images/posts/thumbs/";

            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files["Thumbnail"];
                if (file.ContentLength > 0)
                {
                    if (file.ContentLength < MAX_IMG_SIZE)
                    {
                        byte[] imageSize = new byte[file.ContentLength];
                        file.InputStream.Read(imageSize, 0, (int)file.ContentLength);
                        string filePath     = Server.MapPath(pathRoot) + file.FileName;
                        string fileName     = file.FileName;
                        string fileNameNoEx = Path.GetFileNameWithoutExtension(file.FileName);
                        string ext          = Path.GetExtension(file.FileName).ToLower();
                        if (System.IO.File.Exists(filePath))
                        {
                            int i = 1;
                            filePath = Server.MapPath(pathRoot) + fileNameNoEx + i.ToString() + ext;
                            while (System.IO.File.Exists(filePath))
                            {
                                i++;
                                filePath = Server.MapPath(pathRoot) + fileNameNoEx + i.ToString() + ext;
                                fileName = fileNameNoEx + i.ToString() + ext;
                            }
                        }
                        if (ext == ".jpg" || ext == ".png")
                        {
                            file.SaveAs(filePath);
                            Post post = new Post();
                            post.Header        = Header;
                            post.Summary       = Summary;
                            post.Collection_ID = Collection_ID;
                            post.Date_Added    = DateTime.Now;
                            post.Added_By      = User.Identity.Name.ToString(); ///TODO: Need Auth here
                            post.Archived      = false;
                            post.Thumb_Path    = dbPathRoot + fileName;
                            db.Posts.Add(post);
                            db.SaveChanges();

                            return(RedirectToAction("Edit", new { Post_ID = post.Post_ID, Page_ID = Page_ID, Collection_ID = Collection_ID }));
                        }
                        else
                        {
                            ModelState.AddModelError("", "Only .jpg and .png images are supported");
                            PostCreateViewModel PostViewMod = new PostCreateViewModel();
                            PostViewMod.Collection_ID = Collection_ID;
                            PostViewMod.Page_ID       = Page_ID;
                            return(View(PostViewMod));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Thumbnails must be less than 10 MB");
                        PostCreateViewModel PostViewMod = new PostCreateViewModel();
                        PostViewMod.Collection_ID = Collection_ID;
                        PostViewMod.Page_ID       = Page_ID;
                        return(View(PostViewMod));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "You must selecta 'Thumbnail'");
                    PostCreateViewModel PostViewMod = new PostCreateViewModel();
                    PostViewMod.Collection_ID = Collection_ID;
                    PostViewMod.Page_ID       = Page_ID;
                    return(View(PostViewMod));
                }
            }
            else
            {
                ModelState.AddModelError("", "You must select a 'Thumbnail'");
                PostCreateViewModel PostViewMod = new PostCreateViewModel();
                PostViewMod.Collection_ID = Collection_ID;
                PostViewMod.Page_ID       = Page_ID;
                return(View(PostViewMod));
            }
        }
Beispiel #9
0
        public ActionResult Index(HttpPostedFileBase[] files, string Gallery_Name, int Gallery_ID, int Page_ID)
        {
            Gallery gal = db.Galleries.Find(Gallery_ID);

            try
            {
                /*Lopp for multiple files*/
                string retView = "";
                foreach (HttpPostedFileBase ImgFile in files)
                {
                    Regex  r             = new Regex("[^a-zA-Z0-9]");
                    string dirName       = r.Replace(Gallery_Name, "");
                    string pathRoot      = "~/" + IMAGE_BASE_ROOT + dirName + "/";
                    string pathRootTemp  = "~/" + IMAGE_BASE_ROOT + dirName + "/uploadTemp/";
                    string dbRoot        = IMAGE_BASE_ROOT + dirName + "/";
                    string displayRoot   = "/" + IMAGE_BASE_ROOT + dirName + "/";
                    string fileNameNoExt = System.IO.Path.GetFileNameWithoutExtension(ImgFile.FileName);
                    string ext           = System.IO.Path.GetExtension(ImgFile.FileName).ToLower();
                    if (ext == ".jpg" || ext == ".png")
                    {
                        if (!System.IO.Directory.Exists(Server.MapPath(pathRoot)))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(pathRoot));
                        }
                        if (!System.IO.Directory.Exists(Server.MapPath(pathRootTemp)))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(pathRootTemp));
                        }

                        string filePath     = Server.MapPath(pathRoot) + ImgFile.FileName;
                        string filePathTemp = Server.MapPath(pathRootTemp) + ImgFile.FileName;
                        string displayPath  = displayRoot + ImgFile.FileName;
                        string retName      = "";
                        try
                        {
                            retName       = UploadFile(ImgFile, pathRootTemp, fileNameNoExt, ext);
                            filePathTemp  = Server.MapPath(pathRootTemp) + retName + ext;
                            filePath      = Server.MapPath(pathRoot) + retName + ext;
                            displayPath   = displayRoot + retName + ext;
                            fileNameNoExt = retName;
                        }
                        catch (Exception ex)
                        {
                            return(Json(new { error = "Upload Failed", message = ex.Message }));
                        }

                        //scaling image
                        Image origImg = Bitmap.FromFile(filePathTemp);
                        int   width   = origImg.Width;
                        int   height  = origImg.Height;

                        if (width > height)
                        {
                            if (width > GALLERY_IMG_WIDTH)
                            {
                                double origDouble = Convert.ToDouble(width);
                                double maxDouble  = Convert.ToDouble(GALLERY_IMG_WIDTH);
                                double perc       = 1 - ((origDouble - maxDouble) / origDouble);
                                width  = Convert.ToInt32(Convert.ToDouble(width) * perc);
                                height = Convert.ToInt32(Convert.ToDouble(height) * perc);
                                Size  newSize  = new Size(width, height);
                                Image newImage = (Image)(new Bitmap(origImg, newSize));
                                //System.IO.File.Delete(filePath);
                                if (System.IO.File.Exists(filePath))
                                {
                                    int i = 1;
                                    filePath = Server.MapPath(pathRoot) + fileNameNoExt + i.ToString() + ext;
                                    retName  = fileNameNoExt + i.ToString();

                                    while (System.IO.File.Exists(filePath))
                                    {
                                        i++;
                                        filePath = Server.MapPath(pathRoot) + fileNameNoExt + i.ToString() + ext;
                                        retName  = fileNameNoExt + i.ToString();
                                    }
                                    fileNameNoExt = retName;
                                    displayPath   = displayRoot + retName + ext;
                                }
                                if (ext == ".jpg")
                                {
                                    newImage.Save(filePath, ImageFormat.Jpeg);
                                }
                                else if (ext == ".png")
                                {
                                    newImage.Save(filePath, ImageFormat.Png);
                                }
                                newImage.Dispose();
                            }
                            else
                            {
                                retName       = UploadFile(ImgFile, pathRoot, fileNameNoExt, ext);
                                filePath      = Server.MapPath(pathRoot) + retName + ext;
                                displayPath   = displayRoot + retName + ext;
                                fileNameNoExt = retName;
                            }
                        }
                        else
                        {
                            if (height > GALLERY_IMG_HEIGHT)
                            {
                                double origDouble = Convert.ToDouble(height);
                                double maxDouble  = Convert.ToDouble(GALLERY_IMG_HEIGHT);
                                double perc       = 1 - ((origDouble - maxDouble) / origDouble);
                                width  = Convert.ToInt32(Convert.ToDouble(width) * perc);
                                height = Convert.ToInt32(Convert.ToDouble(height) * perc);
                                Size  newSize  = new Size(width, height);
                                Image newImage = (Image)(new Bitmap(origImg, newSize));

                                if (System.IO.File.Exists(filePath))
                                {
                                    int i = 1;
                                    filePath = Server.MapPath(pathRoot) + fileNameNoExt + i.ToString() + ext;
                                    retName  = fileNameNoExt + i.ToString();
                                    while (System.IO.File.Exists(filePath))
                                    {
                                        i++;
                                        filePath = Server.MapPath(pathRoot) + fileNameNoExt + i.ToString() + ext;
                                        retName  = fileNameNoExt + i.ToString();
                                    }
                                    fileNameNoExt = retName;
                                    displayPath   = displayRoot + retName + ext;
                                }

                                if (ext == ".jpg")
                                {
                                    newImage.Save(filePath, ImageFormat.Jpeg);
                                }
                                else if (ext == ".png")
                                {
                                    newImage.Save(filePath, ImageFormat.Png);
                                }
                                newImage.Dispose();
                            }
                            else
                            {
                                retName       = UploadFile(ImgFile, pathRoot, fileNameNoExt, ext);
                                filePath      = Server.MapPath(pathRoot) + retName + ext;
                                displayPath   = displayRoot + retName + ext;
                                fileNameNoExt = retName;
                            }
                        }
                        origImg.Dispose();

                        Photo photo = new Photo();
                        photo.File_Path  = dbRoot + fileNameNoExt + ext;
                        photo.Thumb_Path = dbRoot + fileNameNoExt + ext;
                        photo.Archived   = false;
                        photo.Added_By   = User.Identity.Name.ToString();///TODO:auth
                        photo.Date_Added = DateTime.Now;
                        photo.Gallery    = gal;
                        db.Photos.Add(photo);
                        db.SaveChanges();

                        //var files = new List<object>();
                        //files.Add(new { url = displayPath.Replace("\\", "\\/"), thumbnailUrl = displayPath.Replace("\\", "\\/"), name = ImgFile.FileName, type = "image/jpeg", size = ImgFile.ContentLength, deleteUrl = displayPath.Replace("\\", "\\/"), deleteType = "DELETE" });
                        //return Json(files, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        return(Json(new { error = "Upload Failed", message = "Not a  supported image format" }));
                    }

                    ///*Geting the file name*/
                    //string filename = System.IO.Path.GetFileName(file.FileName);
                    ///*Saving the file in server folder*/
                    //retView += "<img src=\"images/"+filename+"\" alt=\"Image Not Found\"/>";
                    //file.SaveAs(Server.MapPath("~/images/" + filename));
                    //string filepathtosave = "Images/" + filename;
                    ///*HERE WILL BE YOUR CODE TO SAVE THE FILE DETAIL IN DATA BASE*/
                    retView += "<img src=\"/" + dbRoot + fileNameNoExt + ext + "\" alt=\"Image Not Found\"/>";
                }

                ViewBag.Message = retView;
            }
            catch
            {
                ViewBag.Message = "Error while uploading the files.";
            }
            GalleryEditViewModel vm = new GalleryEditViewModel(Page_ID, gal);

            return(View());
        }
Beispiel #10
0
 public ActionResult Create([Bind(Include = "pageName,url,displayName,defaultPage, parentPageID, displayInMenu")] PageCreateViewModel pageViewModel)
 {
     if (db.Pages.Where(x => x.URL.ToLower() == pageViewModel.url.ToLower()).Count() <= 0)
     {
         if (db.Pages.Where(x => x.Page_Name.ToLower() == pageViewModel.pageName.ToLower()).Count() <= 0)
         {
             Page page = new Page();
             page.Page_Name       = pageViewModel.pageName;
             page.URL             = pageViewModel.url;
             page.Title_Text      = pageViewModel.displayName;
             page.Is_Default      = pageViewModel.defaultPage;
             page.Display_In_Menu = pageViewModel.displayInMenu;
             page.Redirect        = false;
             if (pageViewModel.parentPageID != 0)
             {
                 page.Parent_Page_ID = pageViewModel.parentPageID;
                 page.Is_Top         = false;
                 Page parentPage = (Page)(from p in db.Pages where p.Page_ID == pageViewModel.parentPageID select p).FirstOrDefault();
                 parentPage.Has_Children = true;
             }
             else
             {
                 page.Is_Top = true;
             }
             page.Date_Added  = DateTime.Now;
             page.Added_By    = User.Identity.Name.ToString(); //TODO:need to add authentication
             page.Sequence_No = 9999;                          //TODO need to allow for changing of page order for admins
             db.Pages.Add(page);
             db.SaveChanges();
             return(RedirectToAction("Edit", new { id = page.Page_ID }));
         }
         else
         {
             ModelState.AddModelError("", "A page with the Page Name '" + pageViewModel.pageName + "' already exists");
             return(View("Create", pageViewModel));
         }
     }
     else
     {
         ModelState.AddModelError("", "A page with the URL '" + pageViewModel.url + "' already exists");
         return(View("Create", pageViewModel));
     }
 }
Beispiel #11
0
        public ActionResult Edit(int Page_ID, int Calender_ID, int Event_ID, string Event_Name, string Description, string Start_Date, string Start_Time, string End_Date, string End_Time, string Location, bool Archived, string Thumb_Path, string Image_Path, bool?Return_Home)
        {
            EventEditViewModel eventViewMod = new EventEditViewModel();

            eventViewMod.Page_ID     = Page_ID;
            eventViewMod.Calender_ID = Calender_ID;
            eventViewMod.Event_ID    = Event_ID;
            eventViewMod.Event_Name  = Event_Name;
            eventViewMod.Description = Description;
            eventViewMod.Start_Date  = Start_Date;
            eventViewMod.Start_Time  = Start_Time;
            eventViewMod.End_Date    = End_Date;
            eventViewMod.End_Time    = End_Time;
            eventViewMod.Archived    = Archived;
            eventViewMod.Location    = Location;
            eventViewMod.Thumb_Path  = Thumb_Path;
            eventViewMod.Image_Path  = Image_Path;
            if (ModelState.IsValid)
            {
                DateTime start = Convert.ToDateTime(Start_Date + " " + Start_Time);
                DateTime end   = Convert.ToDateTime(End_Date + " " + End_Time);
                if (start > end)
                {
                    ModelState.AddModelError("", "Start Date/Time cannot be after End Date/Time");
                    return(View(eventViewMod));
                }
                else
                {
                    Event ev = db.Events.Find(Event_ID);
                    if (Request.Files["Flyer"] != null)
                    {
                        string pathRoot      = "~/" + CAL_IMG_BASE_ROOT;
                        string dbRoot        = CAL_IMG_BASE_ROOT;
                        string pathThumbRoot = "~/" + CAL_IMG_BASE_ROOT + "thumbs/";
                        string dbThumbRoot   = CAL_IMG_BASE_ROOT + "thumbs/";

                        if (!System.IO.Directory.Exists(Server.MapPath(pathRoot)))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(pathRoot));
                        }
                        if (!System.IO.Directory.Exists(Server.MapPath(pathThumbRoot)))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(pathThumbRoot));
                        }

                        HttpPostedFileBase file = Request.Files["Flyer"];
                        if (file.ContentLength > 0)
                        {
                            if (file.ContentLength <= MAX_IMG_SIZE)
                            {
                                string fileNameNoEx = Path.GetFileNameWithoutExtension(file.FileName);
                                string ext          = Path.GetExtension(file.FileName).ToLower();
                                if (ext == ".jpg" || ext == ".png")
                                {
                                    try
                                    {
                                        UploadFile(file, pathRoot, fileNameNoEx, ext);
                                        Image img = Image.FromFile(Server.MapPath(pathRoot) + file.FileName);
                                        if (img.Height > CAL_IMG_HEIGHT)
                                        {
                                            int    width      = img.Width;
                                            int    height     = img.Height;
                                            double origDouble = Convert.ToDouble(height);
                                            double maxDouble  = Convert.ToDouble(CAL_IMG_HEIGHT);
                                            double perc       = 1 - ((origDouble - maxDouble) / origDouble);
                                            width  = Convert.ToInt32(Convert.ToDouble(width) * perc);
                                            height = Convert.ToInt32(Convert.ToDouble(height) * perc);
                                            Size  newSize  = new Size(width, height);
                                            Image newImage = (Image)(new Bitmap(img, newSize));
                                            if (ext == ".jpg")
                                            {
                                                newImage.Save(Server.MapPath(pathThumbRoot) + fileNameNoEx + ext, ImageFormat.Jpeg);
                                            }
                                            else if (ext == ".png")
                                            {
                                                newImage.Save(Server.MapPath(pathThumbRoot) + fileNameNoEx + ext, ImageFormat.Png);
                                            }
                                            else
                                            {
                                                newImage.Save(Server.MapPath(pathThumbRoot) + fileNameNoEx + ext);
                                            }
                                        }
                                        else
                                        {
                                            if (ext == ".jpg")
                                            {
                                                img.Save(Server.MapPath(pathThumbRoot) + fileNameNoEx + ext, ImageFormat.Jpeg);
                                            }
                                            else if (ext == ".png")
                                            {
                                                img.Save(Server.MapPath(pathThumbRoot) + fileNameNoEx + ext, ImageFormat.Png);
                                            }
                                            else
                                            {
                                                img.Save(Server.MapPath(pathThumbRoot) + fileNameNoEx + ext);
                                            }
                                        }
                                        ev.Image_Path = dbRoot + file.FileName;
                                        ev.Thumb_Path = dbThumbRoot + file.FileName;
                                    }
                                    catch (Exception EX)
                                    {
                                        ModelState.AddModelError("", "Failed to upload file. " + EX.Message);
                                        return(View(eventViewMod));
                                    }
                                }
                                else
                                {
                                    ModelState.AddModelError("", "Only .png and .jpg images are supported");
                                    return(View(eventViewMod));
                                }
                            }
                            else
                            {
                                ModelState.AddModelError("", "Flyers/Images must be less than 10 MB");
                                return(View(eventViewMod));
                            }
                        }
                    }

                    ev.Start_Date_Time = start;
                    ev.End_Date_Time   = end;
                    ev.Event_Name      = Event_Name;
                    ev.Description     = Description;
                    ev.Location        = Location;
                    ev.Last_Updated    = DateTime.Now;
                    ev.Updated_By      = User.Identity.Name.ToString();///TODO:auth


                    if (ev.Archived != Archived)
                    {
                        ev.Archived     = Archived;
                        ev.Archive_By   = User.Identity.Name.ToString();///TODO:auth
                        ev.Date_Archive = DateTime.Now;
                    }

                    db.SaveChanges();
                    return(RedirectToAction("Edit", "Calenders", new { Page_ID = Page_ID, Calender_ID = Calender_ID, Return_Home = Return_Home }));
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid Model State.");
                return(View(eventViewMod));
            }
        }