public async Task <IActionResult> Putachivement(int id, achivement achivement) { if (id != achivement.id) { return(BadRequest()); } _context.Entry(achivement).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!achivementExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> ActiveAchivement(int id) { achivement b = _context.achivements.FirstOrDefault(u => u.id == id && u.status == false); if (b != null) { b.status = true; } else { b = null; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!achivementExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <achivement> > Postachivement(achivement achivement) { _context.achivements.Add(achivement); await _context.SaveChangesAsync(); return(CreatedAtAction("Getachivement", new { id = achivement.id }, achivement)); }