Ejemplo n.º 1
0
 public ActionResult Edit(int id, [FromBody] CreateStudentDto dto)
 {
     if (!ModelState.IsValid)
     {
         return(View(dto));
     }
     try
     {
         // TODO: Add update logic here
         _editCommandStd.Execute(dto);
         return(RedirectToAction(nameof(Index)));
     }
     catch (EntityNotFoundException)
     {
         return(RedirectToAction(nameof(Index)));
     }
 }
Ejemplo n.º 2
0
        public ActionResult <IEnumerable <CreateStudentDto> > Put(int id, [FromBody] CreateStudentDto dto)
        {
            dto.Id = id;
            try
            {
                _editCommandStd.Execute(dto);
                return(NoContent());
            }
            catch (EntityNotFoundException e)
            {
                if (e.Message == "Student doesn't exist.")
                {
                    return(NotFound(e.Message));
                }

                return(UnprocessableEntity(e.Message));
            }
            catch (Exception)
            {
                return(StatusCode(500, "error"));
            }
        }