Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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()));
        }
Ejemplo n.º 3
0
 public async Task <IActionResult> Delete([FromRoute] int id)
 {
     TapesService.Delete(await TapesService.GetSingle(id));
     return(NoContent());
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> GetSingle([FromRoute] int id)
        {
            var tape = await TapesService.GetSingle(id);

            return(Ok(tape.ToDto()));
        }