Exemplo n.º 1
0
        public ActionResult Marking()
        {
            string title = "Marking";

            Load(title);

            if (user == null || !user.HasPolicy(new Policy("Store.Marking.Add")))
            {
                return(RedirectToAction("Home", "Main"));
            }

            if (postData != null && postData.ContainsKey("userID") && postData.ContainsKey("date") && postData.ContainsKey("mark"))
            {
                try
                {
                    int      userID  = Convert.ToInt32(postData["userID"]);
                    DateTime date    = Convert.ToDateTime(postData["date"]);
                    int      mark    = Convert.ToInt32(postData["mark"]);
                    string   comment = postData.ContainsKey("comment") ? postData["comment"] : null;

                    SqlStoredProcedures sqlSP = new SqlStoredProcedures();
                    sqlSP.StoreUpdateMarkAndComment(userID, date, mark, comment);

                    return(Content("success"));
                }
                catch
                {
                    return(Content("failed"));
                }
            }
            else
            {
                SqlStoredProcedures sqlSP = new SqlStoredProcedures();

                ViewBag.unmarkedSchedule = sqlSP.StoreSelectUnmarkedSchedule(user.GetUserID());

                return(View(title));
            }
        }