Exemplo n.º 1
0
        public JsonResult CreateSchoolSession(SchoolSession session)
        {
            //if (!User.IsInRole("Admin") || !User.IsInRole("Super Admin"))
            //{
            //    return Json(new { msg = "0", Reason = "Entry Failed, Un-Athourized request!" });
            //}
            if (session.SessionL == null)
            {
                return(Json(new { msg = "0", Reason = "Entry Failed, Session field is required!" }));
            }
            if (session.YearL == null)
            {
                return(Json(new { msg = "0", Reason = "Entry Failed, Year field is required!" }));
            }
            if (session.Term == null)
            {
                return(Json(new { msg = "0", Reason = "Entry Failed, Term field is required!" }));
            }
            if (session.SchoolStart == null)
            {
                return(Json(new { msg = "0", Reason = "Entry Failed, School Start field is required!" }));
            }
            if (session.SchoolEnd == null)
            {
                return(Json(new { msg = "0", Reason = "Entry Failed, School End field is required!" }));
            }

            _sessionRepo = new SchoolSessionRepository();
            int _i = _sessionRepo.Insert(session);

            if (_i > 0)
            {
                return(Json(new { msg = "1", Reason = "Entry Successfull!" }));
            }
            return(Json(new { msg = "0", Reason = "Entry Failed!" }));
        }