public static UserWaterDTO ToUserWaterDTO(UserWaterEntity entity) { return(new UserWaterDTO() { UserId = entity.UserId, Amount = entity.Amount, }); }
public async Task UpsertUserWater(UserWaterEntity entity, DateTime date) { var userWater = await waterContext.UserWater.FirstOrDefaultAsync(e => e.UserId == entity.UserId && e.Created.Date == date.Date); if (userWater == null) { entity.Created = date; entity.Updated = null; waterContext.UserWater.Add(entity); } else { userWater.Updated = date; userWater.Amount = entity.Amount; } await waterContext.SaveChangesAsync(); }