public async Task <IActionResult> Update([FromRoute] int id, [FromBody] TapeInputModel inputModel) { var tape = await TapesService.GetSingle(id); tape.Title = inputModel.Title; tape.Type = inputModel.Type; tape.ReleaseDate = inputModel.ReleaseDate; tape.Eidr = inputModel.Eidr; tape.DirectorFirstName = inputModel.DirectorFirstName; tape.DirectorLastName = inputModel.DirectorLastName; TapesService.Update(tape); return(NoContent()); }
public IActionResult Create([FromBody] TapeInputModel inputModel) { if (!ModelState.IsValid) { return(BadRequest()); } var tape = new Tape { Title = inputModel.Title, Type = inputModel.Type, ReleaseDate = inputModel.ReleaseDate, Eidr = inputModel.Eidr, DirectorFirstName = inputModel.DirectorFirstName, DirectorLastName = inputModel.DirectorLastName, }; TapesService.Create(tape); return(CreatedAtAction(nameof(GetSingle), new { id = tape.Id }, tape.ToDto())); }
public async Task <IActionResult> Delete([FromRoute] int id) { TapesService.Delete(await TapesService.GetSingle(id)); return(NoContent()); }
public async Task <IActionResult> GetSingle([FromRoute] int id) { var tape = await TapesService.GetSingle(id); return(Ok(tape.ToDto())); }