public IActionResult Post([FromBody] HomeworkDTO homeworkDTO) { try { Homework homework = homeworkDTO.ToEntity(); Homework createdHomework = homeworksLogic.Create(homework); HomeworkDTO homeworkToReturn = new HomeworkDTO(createdHomework); return(CreatedAtRoute("Get", new { id = homeworkToReturn.Id }, homeworkToReturn)); } catch (ArgumentException e) { return(BadRequest(e.Message)); } }
public IActionResult Put(Guid id, [FromBody] HomeworkDTO homeworkDTO) { try { Homework homework = homeworkDTO.ToEntity(); Homework updatedHomework = homeworksLogic.Update(id, homework); HomeworkDTO homeworkToReturn = new HomeworkDTO(updatedHomework); return(CreatedAtRoute("Get", new { id = homework.Id }, updatedHomework)); } catch (ArgumentException e) { return(BadRequest(e.Message)); } }