Ejemplo n.º 1
0
        public IHttpActionResult Post(Absence absence)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            absence.Date = absence.Date.AddHours(4);
            absenceRepository.Create(absence);

            return(CreatedAtRoute("DefaultAPI", new { id = absence.Id }, absence));
        }
Ejemplo n.º 2
0
        public ActionResult Create(Absence absence)
        {
            if (ModelState.IsValid)
            {
                repository.Create(absence);

                TempData["message"] = "Запись об отсутствии успешно добавлена";

                return(RedirectToAction("Index"));
            }
            ViewBag.StudentId   = new SelectList(db.Students, "Id", "SecondName", absence.StudentId);
            ViewBag.StudentId2  = new SelectList(db.Students, "Id", "FirstName", absence.StudentId);
            ViewBag.StudentId3  = new SelectList(db.Students, "Id", "MiddleName", absence.StudentId);
            ViewBag.SubjectId   = new SelectList(db.Subjects, "Id", "Name", absence.SubjectId);
            ViewBag.TeacherId   = new SelectList(db.Teachers, "Id", "SecondName", absence.TeacherId);
            ViewBag.TypeClassId = new SelectList(db.TypesClasses, "Id", "Name", absence.TypeClassId);
            return(View(absence));
        }