public async Task UpsertReview(Review review) { var existingReview = await _database.Single <Review>(x => x.UserId == review.UserId && x.RestaurantId == review.RestaurantId); if (existingReview != null) { await _database.Delete <Review>(x => x.Id == review.Id); } await _database.Add(review); }
public async Task DeleteUser(User userToDelete, string password) { var user = (await _database.All <User>()).FirstOrDefault(x => x.Email.Equals(userToDelete.Email)); if (!VerifyPasswordHash(password, user.Password, user.PasswordSalt)) { throw new InvalidOperationException("The paswrod entered is incorrect"); } await _database.Delete <User>(x => x.Email == userToDelete.Email); }
public async Task UpdateStock(List <Item> orderItems) { var restaurant = await _database.Single <Restaurant>(x => x.Menu.Any(m => m.Id == orderItems.FirstOrDefault().FoodId)); foreach (var item in orderItems) { restaurant.Menu.FirstOrDefault(x => x.Id == item.FoodId).Quantity -= item.Quantity; } await _database.Delete <Restaurant>(x => x.Id == restaurant.Id); await _database.Add(restaurant); }
public async Task UpdateOrder(Order order) { await _database.Delete <Order>(x => x.Id == order.Id); await _database.Add(order); }