public async Task <int> AddChild([FromBody] Child child) { child.ChildId = Guid.NewGuid(); await _context.AddAsync(child); return(await _context.SaveChangesAsync()); }
public async Task <IActionResult> PutSleepItem(Guid?id, SleepItem sleepItem) { if (id != sleepItem.SleepId) { return(BadRequest()); } _context.Entry(sleepItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SleepItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <int> AddUser([FromBody] User newUser) { newUser.UserId = Guid.NewGuid(); newUser.UserPassword = _encryptionService.Encrypt(newUser.UserPassword); await _context.Users.AddAsync(newUser); return(await _context.SaveChangesAsync()); }
public async Task <int> AddFeedingItem(FeedingItem feedingItem) { feedingItem.FeedingId = Guid.NewGuid(); feedingItem.FeedingDate = DateTime.Today; feedingItem.TimeSinceLastFeed = TimeSpan.FromSeconds(200); await _context.AddAsync(feedingItem); return(await _context.SaveChangesAsync()); }