예제 #1
0
        public void SaleService_Delete_ShouldBeOk()
        {
            _sale = ObjectMother.GetSale(_product.Object);

            Action Act = () => _service.Delete(_sale);

            Act.Should().NotThrow();
            _repository.Verify(r => r.Delete(_sale.Id));
        }
예제 #2
0
        public void SaleIntegration_Delete_ShouldBeOk()
        {
            _product.Id           = 1;
            _product.Availability = 1;
            _sale    = ObjectMother.GetSaleSql(_product);
            _sale.Id = 1;

            _service.Delete(_sale);
            _expectedSale = _repository.Get(_sale.Id);

            _expectedSale.Should().BeNull();
        }
예제 #3
0
        public IActionResult List()
        {
            List <SoWithItems> soListComplete = new List <SoWithItems>();
            List <Sale>        soList         = iSaleService.GetSales().ToList();

            foreach (var item in soList)
            {
                int         currId   = item.SaleId;
                SoWithItems currItem = GetOrderWithItems(currId);
                soListComplete.Add(currItem);
            }

            foreach (var variable in soListComplete)
            {
                if (iSaleItem != null)
                {
                    var ansList = iSaleItem.GetAll().FirstOrDefault(x => x.SaleId == variable.S.SaleId)?.Returned;
                    if (ansList == null)
                    {
                        iSaleService.Delete(variable.S);
                    }
                }
                variable.S.items = GetTotalSaleItems(variable.S.SaleId);
                variable.S.price = GetTotalSalePrice(variable.S.SaleId);
            }
            List <PoWithItems>   poListComplete = new List <PoWithItems>();
            List <PurchaseOrder> poList         = iPurchaseOrderService.GetAll().ToList();

            foreach (var item in poList)
            {
                int         currId   = item.PurchaseOrderId;
                PoWithItems currItem = GetPOrderWithItems(currId);
                poListComplete.Add(currItem);
            }

            var tongtien = 0.0;

            foreach (var variable in poListComplete)
            {
                tongtien += variable.PurchaseOrder.TotalPrice;
            }
            List <ThongKeTheoThang> result = soListComplete
                                             .GroupBy(l => l.S.SaleDate.Month)
                                             .Select(cl => new ThongKeTheoThang
            {
                Thang    = cl.Select(x => x.S.SaleDate.Month).FirstOrDefault(),
                Soluong  = cl.Count(),
                TongTien = cl.Sum(c => c.S.price),
            }).ToList();

            return(PartialView("List", result));
        }
예제 #4
0
 public async Task <IActionResult> Delete([FromRoute] Guid id)
 {
     if (await _service.Delete(id))
     {
         return(Ok(true));
     }
     return(BadRequest("Lo sentimos no se ha podido eliminar la venta"));
 }
예제 #5
0
        public IActionResult Delete(int id)
        {
            if (!Sales.Exists(id))
            {
                return(NotFound());
            }
            Sales.Delete(id);

            return(RedirectToAction(nameof(All)));
        }
예제 #6
0
 public ActionResult Delete(int id, FormCollection collection, int?page)
 {
     try
     {
         _saleService.Delete(id);
         return(RedirectToAction("Index", new { page = page }));
     }
     catch
     {
         return(View());
     }
 }
예제 #7
0
        public IActionResult DeleteSale(int id)
        {
            var Sale = service.FindById(id);

            if (Sale == null)
            {
                return(NotFound());
            }

            service.Delete(Sale);
            return(Ok());
        }
예제 #8
0
        public ActionResult Delete(int parameter, SaleViewModel model)
        {
            try
            {
                _service.Delete(_service.Get(parameter));

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View(model));
            }
        }
예제 #9
0
 public ActionResult Delete(int id)
 {
     try
     {
         _saleService.Delete(_saleService.GetById(id));
         SuccessNotification("Kayıt Silindi");
         return(RedirectToAction("SaleIndex"));
     }
     catch
     {
         return(View());
     }
 }
        private void BtnClose(object sender, RoutedEventArgs e)
        {
            foreach (var basketDto in UniversalBasketDtos)
            {
                if (!basketDto.IsOwn)
                {
                    _basketService.Delete(basketDto.Id);
                }
                else
                {
                    _basketOwnService.Delete(basketDto.Id);
                }
            }

            _saleService.Delete(_currentSale.Id);
            Close();
        }
예제 #11
0
        public virtual PartialViewResult DeleteSale(int Id)
        {
            var orders = _orderService.GetAllOrderBySaleId(Id);

            _unitOfWork.RemoveRange <Order>(orders);
            _saleService.Delete(_saleService.GetById(Id));
            if (_unitOfWork.SaveAllChanges() > 0)
            {
                return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel {
                    Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessDelete), Status = AlertMode.success
                }));
            }
            else
            {
                return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel {
                    Alert = AlertOperation.SurveyOperation(StatusOperation.FailDelete), Status = AlertMode.warning
                }));
            }
        }
예제 #12
0
 public IActionResult DeleteConfirmed(Guid id)
 {
     _saleService.Delete(id);
     return(Ok());
 }
예제 #13
0
 public IActionResult Delete(int id)
 {
     _saleService.Delete(id);
     return(RedirectToAction(nameof(Items)));
 }
 public IActionResult DeleteSale(int id)
 {
     _service.Delete(id);
     return(Ok("The sale has been successfully deleted!"));
 }
예제 #15
0
        public IActionResult TransactionLookup(string option, string search)
        {
            List <SoWithItems> soListComplete = new List <SoWithItems>();
            List <Sale>        soList         = iSaleService.GetSales().ToList();

            foreach (var item in soList)
            {
                int         currId   = item.SaleId;
                SoWithItems currItem = GetOrderWithItems(currId);
                soListComplete.Add(currItem);
            }

            foreach (var variable in soListComplete)
            {
                if (iSaleItem != null)
                {
                    var ansList = iSaleItem.GetAll().FirstOrDefault(x => x.SaleId == variable.S.SaleId)?.Returned;
                    if (ansList == null)
                    {
                        iSaleService.Delete(variable.S);
                    }
                    variable.S.HoatDong = ansList == 1 ? "RETURNED" : GetStatus(variable.S.SaleId);
                }
                variable.S.items        = GetTotalSaleItems(variable.S.SaleId);
                variable.S.price        = GetTotalSalePrice(variable.S.SaleId);
                variable.S.TenNhanVien  = iEmployeeService.GetById(variable.S.EmployeeId).FullName;
                variable.S.TenKhachHang = iCustomerService.GetById((int)variable.S.CustomerId).FullName;
            }
            //string cacheKey = "Searchfields";
            //bool cacheExists = _cache.TryGetItem(cacheKey, _lastUpdated, out List<SoWithItems> fields);
            //if (!cacheExists)
            //{
            //    fields = soListComplete;
            //    _cache.AddItem(cacheKey, _lastUpdated, fields);
            //}

            if (option == "Tên nhân viên")
            {
                if (search == null)
                {
                    return(View(soListComplete.OrderByDescending(x => x.S.SaleDateString).ThenBy(q => q.S.price).ThenBy(m => m.S.items).Take(15).ToList()));
                }
                var searchcus = soListComplete.Where(x => x.S.TenNhanVien.ToLower().ToString().Contains(search.ToLower())).ToList();
                if (searchcus.Count == 0)
                {
                    return(View(new List <SoWithItems>()));
                }
                return(View(searchcus));
            }
            else if (option == "Tên khách hàng")
            {
                if (search == null)
                {
                    return(View(soListComplete.OrderByDescending(x => x.S.SaleDateString).ThenBy(q => q.S.price).ThenBy(m => m.S.items).Take(15).ToList()));
                }

                var searchcus = soListComplete.Where(x => x.S.TenKhachHang.ToLower().ToString().Contains(search.ToLower())).ToList();
                if (searchcus.Count != 0)
                {
                    return(View(searchcus));
                }
                return(View(new List <SoWithItems>()));
            }
            else
            {
                return(View(soListComplete.OrderByDescending(x => x.S.SaleDateString).ThenBy(q => q.S.price).ThenBy(m => m.S.items).Take(15).ToList()));
            }
        }
예제 #16
0
 public bool Delete(long id)
 {
     saleService = SaleService.Instance;
     return(saleService.Delete(id));
 }
예제 #17
0
 public IHttpActionResult Delete(List <string> ids)
 {
     return(Ok(_service.Delete(ids)));
 }