Exemplo n.º 1
0
 public ActionResult <Student> Create([FromBody] Student newData)
 {
     try
     {
         return(Ok(_ss.Create(newData)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public ActionResult Create(Student student)
        {
            try
            {
                _studentsService.Create(student);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult <Student> Create(Student student)
        {
            try
            {
                _studentsService.Create(student);

                return(CreatedAtRoute("GetStudent", new { id = student.Id.ToString() }, student));
            }
            catch (System.Exception)
            {
                return(Problem(statusCode: 500));
            }
        }
        public void Create_StudentIdNotEmpty_Fail()
        {
            // Arrange
            var course = CoursesRepository.FoundEntity();

            // Act
            var result = _service.Create(new StudentDetails {
                Id = Guid.NewGuid()
            }, course.Id);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Succeed, Is.False);
        }
Exemplo n.º 5
0
 public ActionResult <Students> Create(Students student)
 {
     _studentsService.Create(student);
     return(Ok());
 }
 public void Post([FromBody] Student student)
 {
     _service.Create(student);
 }