public List <Sale> Run(Class class_, DateTime sinceDate, DateTime toDate) { List <Sale> sales = new List <Sale>(); saleRepository.GetNewAll(); foreach (Sale curSale in saleRepository.GetAll()) { if (class_.Id.Equals(curSale.Product.Class.Id) && sinceDate.Ticks <= curSale.Datetime.Ticks && toDate.Ticks >= curSale.Datetime.Ticks) { Sale sale = new Sale() { Id = curSale.Id, Product = curSale.Product, Count = curSale.Count, Price = curSale.Price, Datetime = curSale.Datetime, Seller = curSale.Seller }; sales.Add(sale); } } return(sales); }
private void btnShow_Click(object sender, EventArgs e) { BindingSource newProductSource = new BindingSource(productConnection.GetAll(), null); BindingSource newClientSource = new BindingSource(clientConnection.GetAll(), null); BindingSource newSaleSource = new BindingSource(saleConnection.GetAll(), null); productSource = newProductSource; clientSource = newClientSource; saleSource = newSaleSource; if (cbTables.SelectedIndex == 0) { dataGrid.DataSource = productSource; dataGrid.Columns["Id"].Visible = false; } else if (cbTables.SelectedIndex == 1) { dataGrid.DataSource = clientSource; dataGrid.Columns["Id"].Visible = false; } else if (cbTables.SelectedIndex == 2) { dataGrid.DataSource = saleSource; dataGrid.Columns["Id"].Visible = false; } btnDelete.Enabled = false; btnUpdate.Enabled = false; }
public List <Sale> Run(Department department) { List <Sale> sales = new List <Sale>(); saleRepository.GetNewAll(); foreach (Sale curSale in saleRepository.GetAll()) { if (department.Id.Equals(curSale.Product.ArrivedGoods.Department.Id)) { Sale sale = new Sale() { Id = curSale.Id, Product = curSale.Product, Count = curSale.Count, Price = curSale.Price, Datetime = curSale.Datetime, Seller = curSale.Seller }; sales.Add(sale); } } return(sales); }
public IEnumerable <SaleDto> GetAllSales() { var sales = _saleRepo.GetAll(); var result = Mapping.Mapper.Map <IEnumerable <SaleDto> >(sales); return(result); }
public void SaleSqlRepository_GetAll_ShoulBeOK() { //Executa IEnumerable <Sale> resultado = _repository.GetAll(); //Verifica resultado.Count().Should().BeGreaterThan(0); }
public IActionResult Get(int?page, int count, string sortColumn, string direction = "asc", string country = "") { PageEntitiesContainer <Sale> pageEntities = new PageEntitiesContainer <Sale>( saleRepository.GetAll().Include(s => s.Country).Include(s => s.ItemType), saleRepository); pageEntities.RegisterFilter(new Filter(typeof(Country), country)); switch (sortColumn) { case "orderDate": pageEntities.OrderBy(s => s.OrderDate, direction); break; } pageEntities.SetPage(page, count > 0 ? count : 50); return(Ok(Mapper.Map <PageEntitiesContainerDto <SaleDto> >(pageEntities))); }
public void SaleRepository_GetAll_ShouldBeOk() { var id = 1; _expectedListSale = _repository.GetAll(); _expectedListSale.Count().Should().Be(1); _expectedListSale.Last().Id.Should().Be(id); }
public IEnumerable <SaleModel> GetAll() { var saleData = _iSaleRepository.GetAll(); Mapper.Initialize(map => { map.CreateMap <Sale, SaleModel>(); }); var saleDetail = Mapper.Map <IEnumerable <Sale>, IEnumerable <SaleModel> >(saleData); return(saleDetail); }
public async Task <IEnumerable <SaleDto> > GetAll() { try { var sales = (await _saleRepository.GetAll(x => x.Include(s => s.Client).Include(s => s.Payment).Include(s => s.Details).ThenInclude(d => d.Product))) .OrderByDescending(x => x.Date); foreach (var sale in sales) { sale.Details = sale.Details.Where(x => !x.IsDeleted).ToList(); } var salesDto = _mapper.Map <IEnumerable <Sale>, IEnumerable <SaleDto> >(sales); return(await SetSalePayments(sales, salesDto)); } catch (Exception e) { throw e; } }
public Form1() { productConnection = new ProductRepository(); clientConnection = new ClientRepository(); saleConnection = new SaleRepository(); productSource = new BindingSource(productConnection.GetAll(), null); clientSource = new BindingSource(clientConnection.GetAll(), null); saleSource = new BindingSource(saleConnection.GetAll(), null); Application.ThreadException += new ThreadExceptionEventHandler(Form1_UIThreadException); InitializeComponent(); }
public IList <GetSaleListModel> Execute() { var sales = from s in _saleRepository.GetAll() select new GetSaleListModel { Id = s.Id, CustomerName = s.Customer.Name, EmployeeName = s.Employee.Name, ProductName = s.Product.Name, UnitPrice = s.UnitPrice, Quantity = s.Quantity, TotalPrice = s.TotalPrice }; return(sales.ToList()); }
public void GetSalesShouldReturnSalesQuantity() { ISaleRepository saleRepository = Substitute.For <ISaleRepository>(); IMapper mapper = Substitute.For <IMapper>(); string sales = Data.ResourceManager.GetString("Sales"); IEnumerable <Sale> lstSales = JsonConvert.DeserializeObject <IEnumerable <Sale> >(sales); saleRepository.GetAll().Returns(lstSales); //ISaleCore controller = new SaleCore(saleRepository, mapper); //var result = controller.GetAll(); //result.Should().HaveCount(6); }
public List <SalesListItemModel> Execute() { var sales = _repository.GetAll() .Select(p => new SalesListItemModel() { Id = p.Id, Date = p.Date, CustomerName = p.Customer.Name, EmployeeName = p.Employee.Name, ProductName = p.Product.Name, UnitPrice = p.UnitPrice, Quantity = p.Quantity, TotalPrice = p.TotalPrice }); return(sales.ToList()); }
public SaleDetailModel Execute(int saleId) { var sale = _repository.GetAll() .Where(p => p.Id == saleId) .Select(p => new SaleDetailModel() { Id = p.Id, Date = p.Date, CustomerName = p.Customer.Name, EmployeeName = p.Employee.Name, ProductName = p.Product.Name, UnitPrice = p.UnitPrice, Quantity = p.Quantity, TotalPrice = p.TotalPrice }) .Single(); return(sale); }
public async Task <IEnumerable <SaleDto> > GetAllSales() { var dataToReturn = new List <SaleDto>(); var allSales = await _saleRepository.GetAll().ToListAsync(); foreach (var allSale in allSales) { var saleDetails = await _saleDetailRepository.FindBy(x => x.SaleId == allSale.Id).ToListAsync(); dataToReturn.Add(new SaleDto { CustomerId = allSale.CustomerId, Total = allSale.Total, SaleDetailDtos = saleDetails.Select(x => new SaleDetailDto { ProductId = x.ProductId, Quantity = x.Quantity }) }); } return(dataToReturn); }
public async Task <object> GetAll() { List <Sale> listSale = new List <Sale>(); try { listSale = _saleRepository.GetAll(); } catch (Exception ex) { result = false; error = ex.Message; } return(new SingleResponse <List <Sale> > { Message = "Get all sale execute successfully", DidError = false, ErrorMessage = string.Empty, Token = string.Empty, Model = listSale }); }
public IEnumerable <Sale> GetAll() { return(_sales.GetAll()); }
public async Task <List <Sale> > GetSales(CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); return(await _saleRepository.GetAll(cancellationToken)); }
public IEnumerable <SaleDto> GetAll() { return(_mapper.Map <IEnumerable <SaleDto> >(_saleRepository.GetAll())); }
public List <Sale> GetAll() { return(_repository.GetAll()); }
public IEnumerable <SaleViewModel> GetAll() { return(mapper.Map <IEnumerable <SaleViewModel> >(saleRepository.GetAll())); }
public ViewResult All() { var list = repository.GetAll(); return(View(list.ToList())); }
public async Task <IEnumerable <Sale> > ListAsync() { var sales = await _saleRepository.GetAll(); return(sales); }
public IEnumerable <Sale> GetAll() { return(Repository.GetAll()); }
// GET: Sales public IActionResult Index() { return(View(saleRepository.GetAll())); }
public IEnumerable <SaleDTO> GetAllSale() { IEnumerable <Sale> list = saleRepository.GetAll(); return(list.MappingSaleDtos()); }
public List <Sale> GetAll() { return(_saleRepository.GetAll().ToList()); }
public IActionResult GetSoldOrders(int country, int year) { return(Ok(saleRepository.GetAll().Count(s => s.Country.Id == country && s.OrderDate.Year == year))); }
public List <ReportDetailed> Run(Category category, DateTime sinceDate, DateTime toDate) { List <ReportDetailed> reportDetaileds = new List <ReportDetailed>(); int id = 0; classRepository.GetNewAll(); foreach (Class curClass in classRepository.GetAll()) { id++; int arrivedCount = 0; int saledCount = 0; int returnedCount = 0; float sum = 0.0f; float revenue = 0.0f; float percentRevenue = 0.0f; productRepository.GetNewAll(); foreach (Product curProduct in productRepository.GetAll()) { if (curClass.Id == curProduct.Class.Id && category.Id == curProduct.Category.Id) { if (sinceDate <= curProduct.ArrivedGoods.DateTime && toDate >= curProduct.ArrivedGoods.DateTime) { arrivedCount += curProduct.ArrivedGoods.Count; } if (curProduct.ReturnedDate != null) { if (sinceDate <= curProduct.ReturnedDate.Value && toDate >= curProduct.ReturnedDate.Value && curProduct.Returned) { returnedCount++; } } } } saleRepository.GetNewAll(); foreach (Sale curSale in saleRepository.GetAll()) { if (sinceDate <= curSale.Datetime && toDate >= curSale.Datetime && curClass.Id == curSale.Product.Class.Id && category.Id == curSale.Product.Category.Id) { saledCount += curSale.Count; sum += curSale.Price; revenue += curSale.Price - curSale.Product.PurchasePrice; } } foreach (Sale curSale in saleRepository.GetAll()) { if (sinceDate <= curSale.Datetime && toDate >= curSale.Datetime && curClass.Id == curSale.Product.Class.Id && category.Id == curSale.Product.Category.Id) { float curRevenue = curSale.Price - curSale.Product.PurchasePrice; percentRevenue = (revenue * curRevenue) / 100f; } } ReportDetailed reportDetailed = new ReportDetailed() { Id = id, Category = category, Class = curClass, ArrivedCount = arrivedCount, SaledCount = saledCount, ReturnedCount = returnedCount, Sum = sum, Revenue = revenue, PercentRevenue = percentRevenue, }; reportDetaileds.Add(reportDetailed); } return(reportDetaileds); }
IEnumerable <Sale> ISalesAppService.GetAll(int skip, int limit) { return(_repository.GetAll(skip, limit)); }