Пример #1
0
        public ActionResult StudentGrades_Read([DataSourceRequest] DataSourceRequest request)
        {
            IQueryable <StudentGrade> items  = StudentGrade.GetAll().AsQueryable();
            DataSourceResult          result = items.ToDataSourceResult(request, _item => new
            {
                Id   = _item.Id,
                Name = _item.Name,
                // IsDeleted = _item.IsDeleted,
                CreatedOn         = _item.CreatedOn,
                CreatedByUserId   = _item.CreatedByUserId,
                CreatedByUserName = _item.CreatedByUserName
            });

            return(Json(result));
        }
Пример #2
0
 public ActionResult AddNewStudent(Student model)
 {
     ViewBag.AlreadyExists = false;
     ViewBag.AllSchools    = new SelectList(School.GetAll(), "Id", "Name");
     ViewBag.AllClasses    = new SelectList(StudentClass.GetAll(), "Id", "Name");
     ViewBag.AllGrades     = new SelectList(StudentGrade.GetAll(), "Id", "Name");
     ViewBag.AllCities     = new SelectList(City.GetAll(), "Id", "Name");
     if (model.Id != 0)
     {
         Student st = Student.GetById(model.Id);
         model.School         = st.School;
         model.SchoolId       = st.SchoolId;
         model.StudentClass   = st.StudentClass;
         model.StudentClassId = st.StudentClassId;
         model.StudentGrade   = st.StudentGrade;
         model.StudentGradeId = st.StudentGradeId;
     }
     if (ModelState.IsValid)
     {
         if (model.Id != 0)
         {
             bool IsUpdated = Student.Update(model.Id, model.FirstName, model.LastName, model.Gender, model.DOB, model.PrimaryParent,
                                             model.Address, model.State, model.MotherCell, model.SecondaryParent, model.Phone,
                                             model.FatherCell);
             if (IsUpdated)
             {
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             bool isAdded = Student.AddNew(model.SchoolId, model.StudentClassId, model.StudentGradeId,
                                           model.CityId, model.FirstName, model.LastName, model.Gender, model.DOB, model.PrimaryParent,
                                           model.Address, model.State, model.MotherCell, model.SecondaryParent, model.Phone,
                                           model.FatherCell, ApplicationHelper.LoggedUserId);
             if (isAdded)
             {
                 return(RedirectToAction("Index"));
             }
         }
         ViewBag.AlreadyExists = true;
         return(View(model));
     }
     else
     {
         return(View(model));
     }
 }
Пример #3
0
        public ActionResult AddNewStudent(int?id)
        {
            if (id != null)
            {
                ViewBag.AlreadyExists = false;

                Student _item = Student.GetById(id.Value);
                ViewBag.AllSchools = new SelectList(School.GetAll(), "Id", "Name");
                ViewBag.AllClasses = new SelectList(StudentClass.GetAll(), "Id", "Name");
                ViewBag.AllGrades  = new SelectList(StudentGrade.GetAll(), "Id", "Name");
                ViewBag.AllCities  = new SelectList(City.GetAll(), "Id", "Name");
                return(View(_item));
            }
            else
            {
                ViewBag.AlreadyExists = false;
                ViewBag.AllSchools    = new SelectList(School.GetAll(), "Id", "Name");
                ViewBag.AllClasses    = new SelectList(StudentClass.GetAll(), "Id", "Name");
                ViewBag.AllGrades     = new SelectList(StudentGrade.GetAll(), "Id", "Name");
                ViewBag.AllCities     = new SelectList(City.GetAll(), "Id", "Name");
                Student _item = new Student();
                return(View(_item));
            }
        }