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)); }
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(); }
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)); }
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")); }
public IActionResult Delete(int id) { if (!Sales.Exists(id)) { return(NotFound()); } Sales.Delete(id); return(RedirectToAction(nameof(All))); }
public ActionResult Delete(int id, FormCollection collection, int?page) { try { _saleService.Delete(id); return(RedirectToAction("Index", new { page = page })); } catch { return(View()); } }
public IActionResult DeleteSale(int id) { var Sale = service.FindById(id); if (Sale == null) { return(NotFound()); } service.Delete(Sale); return(Ok()); }
public ActionResult Delete(int parameter, SaleViewModel model) { try { _service.Delete(_service.Get(parameter)); return(RedirectToAction("Index")); } catch { return(View(model)); } }
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(); }
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 })); } }
public IActionResult DeleteConfirmed(Guid id) { _saleService.Delete(id); return(Ok()); }
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!")); }
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())); } }
public bool Delete(long id) { saleService = SaleService.Instance; return(saleService.Delete(id)); }
public IHttpActionResult Delete(List <string> ids) { return(Ok(_service.Delete(ids))); }