//
        // GET: /Administrator/Awards/

        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;
                Awards awardsModels = new Awards();
                decimal totalAward = awardsModels.TotalAward();
                int totalPage = (int)Math.Ceiling(Convert.ToDecimal(totalAward / totalRecord));
                Paging.numPage = totalPage;
                Paging.numLinkDisplay = GlobalInfo.NumLinkPagingDisplay;
                Paging.currentPage = currentPage;
                string url = "administrator/awards/index";
                ViewBag.pagingString = Paging.GenerateLinkPaging(url);
                ViewBag.Title += " Awards";
                return View(awardsModels.ListAward((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_award"] != null)
         {
             StringBuilder stringBuilder = new StringBuilder();
             stringBuilder.Append("<ul>");
             Strings stringsLibs = new Strings();
             if (form["Name"].Trim() == "")
             {
                 stringBuilder.Append("<li>Please type competition name</li>");
             }
             if (form["Level"] == "-1")
             {
                 stringBuilder.Append("<li>Please choose level for this award</li>");
             }
             if (form["Description"].Trim() == "")
             {
                 stringBuilder.Append("<li>Please type competition description</li>");
             }
             if (stringBuilder.ToString() == "<ul>")
             {
                 Awards award = new Awards
                 {
                     Name = form["Name"],
                     DateUpdate = DateTime.Now,
                     Description = form["Description"].Trim(),
                     Level = Convert.ToInt16(form["Level"])
                 };
                 db.Awards.Add(award);
                 db.SaveChanges();
                 ViewBag.success = "Add award success!";
             }
             else
             {
                 stringBuilder.Append("</ul>");
                 ViewBag.error = stringBuilder.ToString();
                 ViewBag.dataForm = form;
             }
         }
         ViewBag.maxLevel = db.Awards.Max(a => a.Level);
         return View();
     }
     else
     {
         Session["errorContorllerAction"] = true;
         return Redirect("~/administrator");
     }
 }