예제 #1
0
        public List <SupplierOrderDTO> GetSupplierOrdersDTO(int SupplierID)
        {
            List <SupplierOrderDTO> result = new List <SupplierOrderDTO>();
            SupplierOrderDTO        dto;

            using (BadgerDataModel ctx = new BadgerDataModel())
            {
                // Get all the Suppliers Orders --
                var pOrders = ctx.PurchaseOrder.Where(p => p.SupplierId == SupplierID).ToList();

                foreach (var P in pOrders)
                {
                    dto = new SupplierOrderDTO();
                    dto.PurchaserName = P.Employee.Lastname;
                    if (P.Job != null)
                    {
                        dto.JobName = P.Job.Jobname;
                    }

                    dto.OrderDate     = P.OrderDate;
                    dto.OrderNum      = P.OrderNum;
                    dto.Received      = P.Recieved;
                    dto.SupplierName  = P.Supplier.SupplierName;
                    dto.ReceiveStatus = "none";
                    result.Add(dto);
                }
            }

            return(result);
        }
예제 #2
0
        public async Task <ActionResult> Create(IFormCollection collection)
        {
            try
            {
                var supplierId = int.Parse(collection["SupplierId"].FirstOrDefault());
                var itemsIds   = collection["Items"].Select(i => int.Parse(i));
                var Counts     = collection["Counts"].Select(i => int.Parse(i));
                var Prices     = collection["Prices"].Select(i => Price.Parse(i));

                var items = itemsIds.Zip(Counts).Zip(Prices).Select((idCountPrice) => new SupplierOrderItemDTO
                {
                    ProductId       = idCountPrice.First.First,
                    Number          = idCountPrice.First.Second,
                    SupplierOrderId = supplierId,
                    Price           = idCountPrice.Second,
                });

                var supplierOrder = new SupplierOrderDTO
                {
                    SupplierId = int.Parse(collection["SupplierId"]),
                    UserId     = User.GetUserId(),
                    Items      = items.ToList(),
                };

                await _supplierOrderService.Create(User, supplierOrder);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        private void dgSupplierOrders_SelectionChanged(object sender, EventArgs e)
        {
            DataGridView     dg        = (DataGridView)sender;
            SupplierOrderDTO selection = (SupplierOrderDTO)dg.CurrentRow.DataBoundItem;

            selectedOrder = selection.OrderNum.Value;
            this.dgSupplierClaims.DataSource = claimService.SupplierClaims(2280);
        }
예제 #4
0
        public async Task Create(ClaimsPrincipal User, SupplierOrderDTO order)
        {
            order.UserId      = User.GetUserId();
            order.DateTime    = DateTime.Now;
            order.ResultPrice = new Price(order.Items.Sum(p => p.Price.Penny * p.Number));
            var status = new SupplierOrderSupplierOrderStatusDTO
            {
                DateTime = DateTime.Now,
                SupplierOrderStatusId = (await _statusService.GetOrCreateByStatusStringAsync("Ожидание оплаты")).Id,
            };

            order.Statuses = new List <SupplierOrderSupplierOrderStatusDTO> {
                status
            };

            await _repo.CreateAsync(_mapper.Map <SupplierOrder>(order));
        }