private async void DeleteMethod()
        {
            MessageDialogResult result = await _currentWindow.ShowMessageAsync("تأكيد الحذف", "هل تـريــد حــذف هـذه الفاتورة؟", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
            {
                AffirmativeButtonText = "موافق",
                NegativeButtonText    = "الغاء",
                DialogMessageFontSize = 25,
                DialogTitleFontSize   = 30
            });

            if (result == MessageDialogResult.Affirmative)
            {
                _safeServ.DeleteSafe(_selectedSale.RegistrationDate);
                _clientAccountServ.DeleteAccount(_selectedSale.RegistrationDate);
                var saleCategories = _saleCategoryServ.GetSaleCategories(_selectedSale.ID);
                foreach (var item in saleCategories)
                {
                    Category cat = _categoryServ.GetCategory(item.CategoryID);
                    if (cat.Qty + item.Qty != 0)
                    {
                        cat.Cost = (item.CostTotal + (cat.Cost * cat.Qty)) / (cat.Qty + item.Qty);
                    }
                    cat.Qty = cat.Qty + item.Qty;
                    _categoryServ.UpdateCategory(cat);
                }
                _saleServ.DeleteSale(_selectedSale);
                Load();
            }
        }
示例#2
0
        public HttpResponseMessage DeleteSale(int saleID)
        {
            var deletedSale = SaleServices.DeleteSale(saleID);

            var response = Request.CreateResponse(HttpStatusCode.OK, deletedSale, Configuration.Formatters.JsonFormatter);

            response.Headers.Add("API-Version", apiVersion);
            response.Headers.Add("Response-Type", "JSON");

            if (deletedSale == null)
            {
                var notFoundResponse = Request.CreateResponse(HttpStatusCode.NotFound, "(404) Sale not found",
                                                              Configuration.Formatters.JsonFormatter);

                notFoundResponse.Headers.Add("API-Version", apiVersion);

                return(notFoundResponse);
            }
            else
            {
                return(response);
            }
        }