//
        // GET: /Administrator/Conditions/

        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;
                Conditions conditionsModels = new Conditions();
                decimal totalCondition = conditionsModels.TotalCondition();
                int totalPage = (int)Math.Ceiling(Convert.ToDecimal(totalCondition / totalRecord));
                Paging.numPage = totalPage;
                Paging.numLinkDisplay = GlobalInfo.NumLinkPagingDisplay;
                Paging.currentPage = currentPage;
                string url = "administrator/conditions/index";
                ViewBag.pagingString = Paging.GenerateLinkPaging(url);
                ViewBag.Title += " Conditions";
                return View(conditionsModels.ListCondition((int)((currentPage - 1) * totalRecord), (int)totalRecord));
            }
            else
            {
                Session["errorContorllerAction"] = true;
                return Redirect("~/administrator");
            }
        }
 public ActionResult Add(FormCollection form)
 {
     int admin = base.Authentication();
     if (admin == 0)
     {
         return Redirect("~/member/logout");
     }
     else if (admin == 1)
     {
         base.LoadMenu();
         var db = new FineArtContext();
         if (form["submit_condition"] != null)
         {
             StringBuilder stringBuilder = new StringBuilder();
             stringBuilder.Append("<ul>");
             Strings stringsLibs = new Strings();
             if (form["Name"].Trim() == "")
             {
                 stringBuilder.Append("<li>Please type condition name</li>");
             }
             if (form["Description"].Trim() == "")
             {
                 stringBuilder.Append("<li>Please type condition description</li>");
             }
             if (stringBuilder.ToString() == "<ul>")
             {
                 Conditions condition = new Conditions { Name = form["Name"], DateUpdate = DateTime.Now, Description = form["Description"].Trim() };
                 db.Conditions.Add(condition);
                 db.SaveChanges();
                 ViewBag.success = "Add condition success!";
             }
             else
             {
                 stringBuilder.Append("</ul>");
                 ViewBag.error = stringBuilder.ToString();
                 ViewBag.dataForm = form;
             }
         }
         return View();
     }
     else
     {
         Session["errorContorllerAction"] = true;
         return Redirect("~/administrator");
     }
 }