public ActionResult AddStudent(Student student)
        {
            if (ModelState.IsValid)
            {
                _studentData.AddStudent(student);
                return(RedirectToAction(nameof(Index)));
            }

            return(RedirectToAction(nameof(AddStudent)));
        }
Esempio n. 2
0
 public IActionResult Post(Student student)
 {
     if (student != null)
     {
         return(Ok(_studentData.AddStudent(student)));
     }
     else
     {
         return(BadRequest("Eto ta vacio"));
     }
 }
        public IActionResult AddStudent([FromBody] Student student)
        {
            Models.Response response = new Models.Response();

            bool IsAdded = _studentService.AddStudent(student.Name, student.FamilyName, student.Address, student.CountryOfOrigin, student.EmailAddress, student.Age, student.Approved = false, out string message);

            if (!IsAdded)
            {
                response.ResponseCode    = "400";
                response.ResponseMessage = message;
                return(NotFound(new JsonResult(response)));
            }

            response.ResponseCode    = "201";
            response.ResponseMessage = "Student Created Successfully.";
            response.ResponseObject  = student;
            return(Ok(new JsonResult(response)));
        }
Esempio n. 4
0
 public IActionResult AddStudent(Student student)
 {
     _studentData.AddStudent(student);
     return(Created(HttpContext.Request.Scheme + "://" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + student.StudentID, student));
 }