//xóa dữ liệu IDDiscount public void Delete(string id) { if (id != "") { client = new FireSharp.FirebaseClient(config); var discounts = getDiscount(id); //lấy thông tin khuyến mãi var data = new Discount(); SetResponse setResponse = client.Set("Discount/" + id, setnull(data)); DiscountDish discountDish = new DiscountDish(); var danhsachdiscountDish = discountDish.getAll(); foreach (var item in danhsachdiscountDish) { if (item.DishcountTypeID == discounts.IDDiscountType) { discountDish.Delete(item.DiscountDishID); } } var danhsachkhuyenmai = getByidStore(discounts.IDStore); if (danhsachkhuyenmai.Count == 0) //nếu chỉ có 1 khuyến mãi của quán { Store danhsachstore = new Store(); var store = danhsachstore.getByID(discounts.IDStore, 0, 0); foreach (var item2 in store) //tắt biến khuyến mãi của quán thành false { item2.Discount = false; danhsachstore.AddbyidToFireBase(item2.StoreID, item2); } } } }
//Xóa dữ liệu public void Delete(string id) { client = new FireSharp.FirebaseClient(config); var data = new DiscountType(); SetResponse setResponse = client.Set("DiscountType/" + id, setnull(data)); Discount discount = new Discount(); var danhsachdiscount = discount.getAll(); foreach (var item in danhsachdiscount) //xóa khuyến mãi quán { if (item.IDDiscountType == id) { discount.Delete(item.IDDiscount); } } DiscountDish discountDish = new DiscountDish(); var danhsachdiscountdish = discountDish.getAll(); foreach (var item in danhsachdiscountdish) //xóa khuyến mãi món ăn { if (item.DishcountTypeID == id) { discountDish.Delete(item.DiscountDishID); } } }