public async Task <ActionResult <HabitsHistory> > PostHabitsHistory([FromBody] HabitsHistory habitsHistory) { _context.HabitsHistory.Add(habitsHistory); await _context.SaveChangesAsync(); return(CreatedAtAction("GetHabitsHistory", new { id = habitsHistory.Id }, habitsHistory)); }
public async Task <IActionResult> PutHabitsHistory(int id, [FromBody] HabitsHistory habitsHistory) { if (id != habitsHistory.Id) { return(BadRequest()); } _context.Entry(habitsHistory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HabitsHistoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }