public async Task <IActionResult> PutNyhetspuff([FromRoute] int id, [FromBody] Nyhetspuff nyhetspuff) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != nyhetspuff.GuId) { return(BadRequest()); } _context.Entry(nyhetspuff).State = EntityState.Modified; try { _repo.Update(nyhetspuff); var save = await _repo.SaveAsync(nyhetspuff); } catch (DbUpdateConcurrencyException) { if (!NyhetspuffExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostNyhetspuff([FromBody] Nyhetspuff nyhetspuff) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _repo.Add(nyhetspuff); var save = await _repo.SaveAsync(nyhetspuff); return(CreatedAtAction("GetNyhetspuff", new { id = nyhetspuff.GuId }, nyhetspuff)); }