Exemplo n.º 1
0
        public IActionResult Add([FromBody] StudentEntity school)
        {
            try
            {
                studentBusiness.Add(school);
                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest("Não foi possível completar a requisição"));

                throw;
            }
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "StudentId,StudentName,Registration,Email,Date,SeassonId,Address,ContactNo,DepartmentId,SemesterId")] Student student)
        {
            if (string.IsNullOrEmpty(student.Registration))
            {
                string seasson =
                    _seassonBusiness.GetAll()
                    .Where(x => x.SeassonId == student.SeassonId)
                    .Select(x => x.SeassonName)
                    .FirstOrDefault();

                student.Registration = _studentBusiness.GetRegistrationNo(student.DepartmentId, seasson);
            }
            if (ModelState.IsValid)
            {
                _studentBusiness.Add(student);
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentId = new SelectList(_departmentBusiness.GetAll(), "DepartmentId", "DeptName");
            ViewBag.SemesterId   = new SelectList(_semesterBusiness.GetAll(), "SemesterId", "SemesterName");
            ViewBag.SeassonId    = new SelectList(_seassonBusiness.GetAll(), "SeassonId", "SeassonName");
            return(View(student));
        }