public ActionResult Index(string id)
 {
     int admin = base.Authentication();
     if (admin == 0)
     {
         return Redirect("~/member/logout");
     }
     else if (admin == 1)
     {
         base.LoadMenu();
         int currentPage = Paging.GetPage(id);
         decimal totalRecord = GlobalInfo.NumberRecordInPage;
         Exhibitions exhibitionsModels = new Exhibitions();
         decimal totalExhibition = exhibitionsModels.TotalExhibition();
         int totalPage = (int)Math.Ceiling(Convert.ToDecimal(totalExhibition / totalRecord));
         Paging.numPage = totalPage;
         Paging.numLinkDisplay = GlobalInfo.NumLinkPagingDisplay;
         Paging.currentPage = currentPage;
         string url = "administrator/exhibitions/index";
         ViewBag.pagingString = Paging.GenerateLinkPaging(url);
         ViewBag.Title += " Exhibitions";
         return View(exhibitionsModels.ListExhibition((int)((currentPage - 1) * totalRecord), (int)totalRecord));
     }
     else
     {
         Session["errorContorllerAction"] = true;
         return Redirect("~/administrator");
     }
 }
 public ActionResult DesignExhibition(string id)
 {
     int admin = base.Authentication();
     if (admin == 0)
     {
         return Redirect("~/member/logout");
     }
     else if (admin == 1)
     {
         base.LoadMenu();
         try
         {
             int idd = Convert.ToInt16(id);
             Exhibitions exhibitionsModels = new Exhibitions();
             exhibitionsModels.ID = idd;
             exhibitionsModels = exhibitionsModels.GetNavigationWithID("Designs");
             ViewBag.Title += " Designs of " + exhibitionsModels.Name + " Exhibition";
             ViewBag.exhibitionID = idd;
             List<Designs> listDesign = exhibitionsModels.Designs.ToList();
             List<Designs> listDesignNew = new List<Designs>();
             listDesign.ForEach(delegate(Designs design)
             {
                 design = design.GetDesignByID();
                 listDesignNew.Add(design);
             });
             return View(listDesignNew);
         }
         catch
         {
             Session["admin"] = null;
             return Redirect("~/");
         }
     }
     else
     {
         Session["errorContorllerAction"] = true;
         return Redirect("~/administrator");
     }
 }
        public ActionResult Add(FormCollection form, HttpPostedFileBase Images)
        {
            int admin = base.Authentication();
            if (admin == 0)
            {
                return Redirect("~/member/logout");
            }
            else if (admin == 1)
            {
                base.LoadMenu();
                var db = new FineArtContext();
                if (form["submit_exhibition"] != null)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append("<ul>");
                    Strings stringsLibs = new Strings();
                    if (form["Name"].Trim() == "")
                    {
                        stringBuilder.Append("<li>Please type exhibition name</li>");
                    }
                    if (form["Alias"].Trim() == "" || !Validator.ISAlias(form["Alias"]))
                    {
                        stringBuilder.Append("<li>Please type exhibition alias</li>");
                    }
                    else
                    {
                        try
                        {
                            string alias = form["Alias"].Trim().ToString();
                            var exhibition = db.Exhibitions.Where(c => c.Alias == alias).First();
                            stringBuilder.Append("<li>This exhibition alias had been exists in database, try a different</li>");
                        }
                        catch { }
                    }
                    if (form["Description"].Trim() == "")
                    {
                        stringBuilder.Append("<li>Please type exhibition description</li>");
                    }
                    DateTime StartDate = new DateTime();
                    DateTime EndDate = new DateTime();
                    try
                    {
                        StartDate = DateTime.Parse(form["StartDate"]);
                    }
                    catch
                    {
                        stringBuilder.Append("<li>Please type exhibition start date</li>");
                    }
                    try
                    {
                        EndDate = DateTime.Parse(form["EndDate"]);
                    }
                    catch
                    {
                        stringBuilder.Append("<li>Please type exhibition deadline date</li>");
                    }
                    try
                    {
                        if (DateTime.Parse(form["EndDate"]) <= DateTime.Parse(form["StartDate"]))
                        {
                            stringBuilder.Append("<li>End date should after start date</li>");
                        }
                    }
                    catch
                    {

                    }
                    if (Images == null)
                    {
                        stringBuilder.Append("<li>Please chose a image for this exhibition</li>");
                    }
                    if (stringBuilder.ToString() == "<ul>")
                    {
                        ImagesClass objImageClass = new ImagesClass(Images);
                        string fileSaveName = Server.MapPath("~/Content/Images/exhibitions/" + form["Alias"] + ".jpg");
                        objImageClass.CreateNewImage(fileSaveName, 190, 190);
                        Exhibitions exhibitionsModels = new Exhibitions
                        {
                            Name = form["Name"].Trim(),
                            Alias = form["Alias"].Trim(),
                            Image = form["Alias"].Trim() + ".jpg",
                            StartDate = StartDate,
                            EndDate = EndDate,
                            Description = form["Description"].Trim()
                        };
                        db.Exhibitions.Add(exhibitionsModels);
                        db.SaveChanges();
                        ViewBag.success = "Add exhibition success!";
                    }
                    else
                    {
                        stringBuilder.Append("</ul>");
                        ViewBag.error = stringBuilder.ToString();
                        ViewBag.dataForm = form;
                    }
                }
                return View();
            }
            else
            {
                Session["errorContorllerAction"] = true;
                return Redirect("~/administrator");
            }
        }