Beispiel #1
0
        public async Task <PagedList <Sale> > GetSales(SalesParams saleParams)
        {
            var sales = _context.Sales
                        .OrderByDescending(u => u.OrderDate)
                        .AsQueryable();

            if (saleParams.Search != null)
            {
                sales = sales.Where(u => u.Region.Contains(saleParams.Search));
            }


            if (!string.IsNullOrEmpty(saleParams.OrderBy))
            {
                switch (saleParams.OrderBy)
                {
                case "created":
                    sales = sales.OrderByDescending(u => u.OrderDate);
                    break;

                case "shiped":
                    sales = sales.OrderByDescending(u => u.ShipDate);
                    break;

                default:
                    sales = sales.OrderByDescending(u => u.OrderPriority);
                    break;
                }
            }

            return(await PagedList <Sale> .CreateAsync(sales, saleParams.PageNumber, saleParams.PageSize));
        }
Beispiel #2
0
        private void OnOpenSalesEntryCommand(object paramValue)
        {
            if (typeof(SalesParams) != paramValue.GetType())
            {
                var salesParam = new SalesParams()
                {
                    ShowAllCustomers = bool.Parse(paramValue.ToString())
                };
                _documentViewModels.Add(new SalesEntryViewModel(salesParam));
            }
            else
            {
                _documentViewModels.Add(new SalesEntryViewModel(paramValue as SalesParams));
            }

            ActiveDocument = _documentViewModels.Last();
        }
Beispiel #3
0
        public async Task <IActionResult> GetSales([FromQuery] SalesParams salesParams)
        {
            var currentUserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            var userFromRepo = await _repo.GetUser(currentUserId);

            if (currentUserId != userFromRepo.Id)
            {
                return(Unauthorized());
            }


            var sales = await _repo.GetSales(salesParams);

            var salesToReturn = _mapper.Map <IEnumerable <SaleForListDto> >(sales);

            Response.AddPagination(sales.CurrentPage, sales.PageSize,
                                   sales.TotalCount, sales.TotalPages);

            return(Ok(salesToReturn));
        }
Beispiel #4
0
        private void OnOpenSalesEntryTempCommand(object paramValue)
        {
            //check if temp data exists
            if (RMSEntitiesHelper.Instance.RMSEntities.SaleTemps.Count() == 0)
            {
                Utility.ShowErrorBox("No temporary data is available");
                return;
            }

            var tempRecords = RMSEntitiesHelper.Instance.GetNewInstanceOfRMSEntities().SaleTemps.GroupBy(g => g.Guid);

            foreach (var item in tempRecords)
            {
                var salesParams = new SalesParams()
                {
                    GetTemproaryData = true, Guid = item.Key
                };
                _documentViewModels.Add(new SalesEntryViewModel(salesParams));
                ActiveDocument = _documentViewModels.Last();
            }
        }
Beispiel #5
0
        private void HandleKeyDownEvent(object sender, KeyEventArgs e)
        {
            if (!((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == (ModifierKeys.Control | ModifierKeys.Shift)))
            {
                return;
            }

            if (Keyboard.IsKeyDown(Key.P) && Keyboard.IsKeyDown(Key.R))
            {
                Workspace.This.OpenDailyPurchaseReportCommand.Execute(true);
                return;
            }

            if (Keyboard.IsKeyDown(Key.S) && Keyboard.IsKeyDown(Key.R))
            {
                Workspace.This.OpenReturnSalesCommand.Execute(true);
                return;
            }

            switch (e.Key)
            {
            //Sales Entry
            case Key.S:
            {
                var saleParams = new SalesParams()
                {
                    ShowAllCustomers = true, IsTempDataWindow = true
                };
                Workspace.This.OpenSalesEntryCommand.Execute(saleParams);
                return;
            }

            //Sales Amend
            case Key.A:
            {
                try
                {
                    AmendSales amendSales = new AmendSales(true);
                    amendSales.ShowDialog();
                }
                catch (Exceptions.RMSException ex)
                {
                    Utility.ShowErrorBox(ex.Message);
                }
                catch (Exception ex)
                {
                    Utility.ShowErrorBox(ex.Message);
                }
                return;
            }


            //Sales Return
            case Key.P:
            {
                var purchaseParams = new PurchaseParams()
                {
                    ShowAllCompanies = true
                };
                Workspace.This.OpenPurchaseEntryCommand.Execute(purchaseParams);
                return;
            }
            }
        }