public static void DeleteAccount(User userToDelete) { if (userToDelete.Group == Type.Restaurant) { foreach (var r in Restaurants.Where(r => r.OwnerId == userToDelete.Id).ToArray()) { foreach (var d in Dishes.Where(d => d.RestId == r.Id).ToArray()) { Dishes.Remove(d); } Restaurants.Remove(r); } } if (userToDelete.Id == CurrentUser.Id) { LogOut(); } Users.Remove(Users.First(u => u.Id == userToDelete.Id)); foreach (var i in Orders.Items.Where(i => i.UserId == userToDelete.Id)) { Orders.Items.Remove(i); } SaveSystem.SaveAll(); }
public void Delete(int Id) { var restaurant = Get(Id); if (restaurant != null || restaurant == null) { Restaurants.Remove(restaurant); } }
public static void DeleteRestaurant(Restaurant restaurantToDelete) { foreach (var i in Orders.Items.Where(i => i.Item.RestId == restaurantToDelete.Id)) { Orders.Items.Remove(i); } foreach (var d in Dishes.Where(d => d.RestId == restaurantToDelete.Id).ToList()) { Dishes.Remove(d); } Restaurants.Remove(restaurantToDelete); SaveSystem.SaveAll(); CurrentRestaurant = Restaurants.FirstOrDefault(r => r.OwnerId == CurrentUser.Id); if (CurrentRestaurant == null && restaurantToDelete.OwnerId == CurrentUser.Id) { new AddRestaurantWindow().Show(); } }
// DELETE: api/Restaurant/5 public async Task <IHttpActionResult> Delete(ApiId restaurantId) { await _restaurants.Remove(restaurantId); return(StatusCode(HttpStatusCode.Gone)); }