public JsonResult DeleteStudant(StudantGrade studantGrade)
        {
            if (studantGrade == null)
            {
                return(Json(new { Message = "Erro", HasError = true }));
            }

            var dao     = new StudantGradeDAO();
            var message = dao.deleteStudantGrade(studantGrade);

            return(Json(new { Message = message }));
        }
        public string deleteStudantGrade(StudantGrade studantGrade)
        {
            using (var context = new CollegeContext())
            {
                var result = context.StudantGrades.FirstOrDefault(c => c.StudantGradeId == studantGrade.StudantGradeId);

                if (result == null)
                {
                    return("Error");
                }

                context.StudantGrades.Remove(result);
                context.SaveChanges();

                return("Sucess");
            }
        }
        public JsonResult ListStudantGrade(StudantGrade studantGrade)
        {
            if (studantGrade == null)
            {
                return(Json(new { Message = "Error", HasError = true }));
            }

            var dao  = new StudantGradeDAO();
            var List = dao.ListStudantGrade();

            if (!List.Any())
            {
                return(Json(new { Message = "No entry found" }));
            }

            return(Json(List, JsonRequestBehavior.AllowGet));
        }
        public string UpdateStudantGrade(StudantGrade studantGrade)
        {
            using (var context = new CollegeContext())
            {
                var result = context.StudantGrades.FirstOrDefault(c => c.StudantGradeId == studantGrade.StudantGradeId);

                if (result == null)
                {
                    return("Error");
                }

                result.Grade     = studantGrade.Grade;
                result.StudantId = studantGrade.StudantId;
                result.SubjectId = studantGrade.SubjectId;
                context.SaveChanges();

                return("Sucess");
            }
        }
        public string AddStudantGrade(StudantGrade studantGrade)
        {
            using (var context = new CollegeContext())
            {
                var list = ListStudantGrade();

                try
                {
                    context.StudantGrades.Add(studantGrade);
                    context.SaveChanges();
                }

                catch (System.Exception)
                {
                    return("Error");
                }

                return("Sucess");
            }
        }