Esempio n. 1
0
        private async void OrderText_Drop(object sender, DragEventArgs e)
        {
            // If valid ProductID is passed in, add a line item to collection
            if (orderId == 0 && e.DataView.Contains(StandardDataFormats.Text))
            {
                var inventoryId = await e.DataView.GetTextAsync();

                int productId = 0;
                int.TryParse(inventoryId, out productId);
                if (productId > 0)
                {
                    var products = (App.Current as App).Products;
                    var product  = products.GetProductById(productId);
                    if (product != null && !OrderDetails.ProductIdExists(productId))
                    {
                        var lineItem = new OrderDetail();
                        lineItem.ProductID   = productId;
                        lineItem.ProductName = product.ProductName;
                        lineItem.Quantity    = 1;
                        lineItem.UnitPrice   = product.UnitPrice;

                        OrderDetails.Add(lineItem);
                    }
                }
            }
        }
Esempio n. 2
0
 // Click product list view to add an order item
 private void ListView_ItemClick(object sender, ItemClickEventArgs e)
 {
     using (var db = new OrderHelperContext())
     {
         // Find product ID for the clicked item
         int clickedPrdID = (e.ClickedItem as Product).ID;
         // Check if there is existing order item for this product
         OrderDetail orderItem = OrderDetails
                                 .Where(od => od.ProductID == clickedPrdID && String.IsNullOrEmpty(od.Remarks))
                                 .FirstOrDefault();
         // If clicked product does not exist in current order items, create a new item for this product
         if (orderItem == null)
         {
             var productToAdd = db.Products
                                .SingleOrDefault(p => p.ID == clickedPrdID);
             if (productToAdd == null)
             {
                 return;
             }
             var orderDetail = new OrderDetail
             {
                 Quantity  = 1,
                 ProductID = clickedPrdID,
                 UnitPrice = productToAdd.UnitPrice,
                 Product   = productToAdd,
             };
             OrderDetails.Add(orderDetail);
         }
         // If clicked product alreay exist in order list, increase the product quantity by 1
         else
         {
             orderItem.Quantity++;
         }
     }
 }
Esempio n. 3
0
        public void EqualsTest()
        {
            OrderDetails obj1 = new OrderDetails();
            OrderDetails obj2 = new OrderDetails();

            obj1.Add("a", 1);
            obj2.Add("a", 1);
            Assert.AreEqual(obj1, obj2);
        }
Esempio n. 4
0
        public void ToStringTest()
        {
            OrderDetails obj = new OrderDetails();

            obj.Add("a", 1);
            string result = "(a:1;)";

            StringAssert.Equals(obj.ToString(), result);
        }
Esempio n. 5
0
        private void HandleOrderDetails(OrderDetailsMessage message)
        {
            Console.WriteLine("Receive message: {0} {1}", message.Name, message.Price);

            Persist(message, x =>
            {
                Console.WriteLine("PERSIST message: {0} {1}", message.Name, message.Price);
                OrderDetails.Add(x);
            });
        }
Esempio n. 6
0
 public ProductPopupPage AddToCart(OrderDetails expectedOrder)
 {
     expectedOrder.Add(new OrderLine
     {
         Product    = new Product(Name, Price),
         Quantity   = Quantity,
         TotalPrice = Price * Quantity
     });
     return(AddToCart());
 }
Esempio n. 7
0
        //public override int GetHashCode()
        //{
        //    return base.GetHashCode();
        //}

        //增加订单明细项
        public void addDetail(OrderDetail detail)
        {
            if (!OrderDetails.Contains(detail))
            {
                OrderDetails.Add(detail);
            }
            else
            {
                throw new Exception("The detail is already Sexist!!!");
            }
        }
Esempio n. 8
0
        private void HandleOrderDetails(AddOrderDetails command)
        {
            Console.WriteLine("Receive message: {0} {1}", command.Name, command.Price);

            var orderDetails = new OrderDetailsAdded(command.Name, command.Price);

            Persist(orderDetails, x =>
            {
                Console.WriteLine("PERSIST message: {0} {1}", orderDetails.Name, orderDetails.Price);
                OrderDetails.Add(x);
            });
        }
Esempio n. 9
0
 void AddOrderDetails(OrderOptionsData od)
 {
     LineCount++;
     if (!OrderDetails.Contains(od))
     {
         OrderDetails.Add(od);
     }
     else
     {
         OrderDetails.Remove(od);
         OrderDetails.Add(od);
     }
 }
        public async Task FetchOrders()
        {
            try
            {
                OrderDetails.Clear();
                RequestedOrders.Clear();
                CancelOrders.Clear();
                CompleteOrders.Clear();
                ProductList.Clear();
                CustomerOrders orders = await this.orderDataService.GetOrderedItemsAsync();

                if (orders != null)
                {
                    foreach (var item in orders.Data.CustomerInvoiceData)
                    {
                        OrderDetails.Add(item);
                        if (!string.IsNullOrEmpty(item.OrderStatus))
                        {
                            if (item.OrderStatus.ToLower() == "inprogress")
                            {
                                RequestedOrders.Add(item);
                            }
                            else if (item.OrderStatus.ToLower() == "rejected")
                            {
                                CancelOrders.Add(item);
                            }
                            else if (item.OrderStatus.ToLower() == "delivered")
                            {
                                CompleteOrders.Add(item);
                            }
                        }
                    }

                    foreach (var item in orders.Data.InvocieLineItems)
                    {
                        ProductList.Add(item);
                    }
                }
            }
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert("msg", "Unable to load order list", "ok");
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 11
0
        public async Task <IActionResult> OnPost()
        {
            Memberships     = membershipData.GetMemberships();
            ApplicationUser = await userManager.GetUserAsync(User);

            if (ModelState.IsValid)
            {
                foreach (var cartItem in HttpContext.Session.GetObjectFromJson <List <ShoppingCart> >("CartItems").ToList())
                {
                    OrderDetails.Add(new OrderDetail
                    {
                        Product  = productData.GetProductById(cartItem.Id),
                        Quantity = cartItem.Quantity
                    });

                    //
                    Product           = productData.GetProductById(cartItem.Id);
                    Product.Quantity -= cartItem.Quantity;
                    //
                }

                if (Selected != null)
                {
                    var membership = membershipData.GetMembershipById(Convert.ToInt32(Selected));
                    ApplicationUser.Membership = membership;
                    Order.OrderTotal           = cartBL.MemberOnCheckout(Convert.ToDouble(HttpContext.Session.GetString("TotalPrice")), ApplicationUser);
                }
                else
                {
                    Order.OrderTotal = Convert.ToDouble(HttpContext.Session.GetString("TotalPrice"));
                }
                Order.OrderDetails = OrderDetails;
                Order.UserId       = ApplicationUser.Id;
                //
                Order.DateOrdered = DateTime.Now;
                //
                orderData.CreateOrder(Order);
                orderData.Commit();
                HttpContext.Session.Remove("CartItems");
                return(RedirectToPage("/Order/CheckoutComplete"));
            }
            return(Page());
        }
Esempio n. 12
0
        private void HandleOrderDetails(AddOrderDetails command)
        {
            Console.WriteLine("Receive message: {0} {1}", command.Name, command.Price);

            var orderDetails = new OrderDetailsAdded(command.Name, command.Price);

            Persist(orderDetails, x =>
            {
                Console.WriteLine("PERSIST message: {0} {1}", orderDetails.Name, orderDetails.Price);
                OrderDetails.Add(x);

                if (++_counter == 5)
                {
                    Console.WriteLine("SAVE SNAPSHOT");
                    SaveSnapshot(OrderDetails);
                    _counter = 0;
                }
            });
        }
Esempio n. 13
0
        public OrderForPrint GetAndConverOrderDetails(OrderNote targetOrder, EmployeewsOfLocalPOS unitofwork, EmployeewsOfCloudPOS cloudPosUnitofwork)
        {
            // convert
            foreach (var orderDetailsTemp in targetOrder.OrderNoteDetails)
            {
                OrderDetails.Add(new OrderDetailsForPrint()
                {
                    Quan         = orderDetailsTemp.Quan,
                    ProductName  = cloudPosUnitofwork.ProductRepository.Get(p => p.ProductId == orderDetailsTemp.ProductId).First().Name,
                    ProductPrice = cloudPosUnitofwork.ProductRepository.Get(p => p.ProductId == orderDetailsTemp.ProductId).First().Price,

                    ProductId   = orderDetailsTemp.ProductId,
                    ProductType = cloudPosUnitofwork.ProductRepository.Get(p => p.ProductId == orderDetailsTemp.ProductId).First().Type,
                });
            }


            return(this);
        }
Esempio n. 14
0
        protected void lnkDelete_Click(object sender, EventArgs e)
        {
            var lnkbtn = sender as LinkButton;

            if (lnkbtn == null)
            {
                return;
            }
            if (changeActionName == string.Empty)
            {
                var         closeLink = (Control)sender;
                GridViewRow row       = (GridViewRow)closeLink.NamingContainer;
                var         slno      = ((Label)row.FindControl("lblRowIndex")).Text.Trim().ToInt();
                var         partNo    = row.Cells[1].Text.Trim();
                var         qty       = row.Cells[3].Text.Trim().ToDecimal(0);

                var orderDetails = new OrderDetails();
                foreach (var part in GVPartData)
                {
                    if (part.SlNo.Trim().ToInt() == slno)
                    {
                        minSqty(partNo, qty);
                    }
                    else
                    {
                        orderDetails.Add(part);
                    }
                }

                GVPartData = orderDetails;
            }
            else
            {
                if (DeleteEdit == null)
                {
                    return;
                }
                DeleteEdit(sender, e);
            }
            clearForm();
        }
Esempio n. 15
0
        public void AddProduct(Product product)
        {
            var findProduct = OrderDetails
                              .SingleOrDefault(x => x.ProductId == product.Id);

            if (findProduct == null)
            {
                // Not found then add
                OrderDetail od = new OrderDetail();
                od.ProductId = product.Id;
                od.UnitPrice = product.ProductPrice;
                od.Quantity  = 1;
                od.Product   = product;

                OrderDetails.Add(od);
            }
            else
            {
                findProduct.Quantity = findProduct.Quantity + 1;
                // Add, Increment Qty
            }
        }
Esempio n. 16
0
        private async void LoadUserOrders()
        {
            try
            {
                IsBusy = true;
                OrderDetails.Clear();
                var service = new OrderHistoryService();
                var details = await service.GetOrderDetailsAsync();

                foreach (var order in details)
                {
                    OrderDetails.Add(order);
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("error", ex.Message, "ok");
            }
            finally
            {
                IsBusy = true;
            }
        }
Esempio n. 17
0
        protected void Approve(object sender, EventArgs e)
        {
            var orderTransactions = new OrderTransactions();
            var orderDeatils      = new OrderDetails();

            orderDeatils.Add(new OrderDetail {
                SlNo = ForecastingGridViewListControl.Amdno.Trim()
            });
            orderTransactions.Add(new OrderTransaction
            {
                orderHead = new OrderHead
                {
                    OrderNumber = ForecastingGridViewListControl.OrderNumber.Trim(),
                },
                orderDetails = orderDeatils,
                Action       = Constants.UpdateAction,
                DataBaseInfo = UserContext.DataBaseInfo,
                Off          = Constants.TRNCompletedOFF,
            });
            if (_transactionManager.SetFollowupApprove(orderTransactions))
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.ApprovedSaved;
                CustomMessageControl.MessageType     = MessageTypes.Success;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(UserContext, SysEventType.INFO, "Approved Data Saved",
                                  GlobalCustomResource.ApprovedSaved, true);
                fillHeaderGrid();
            }
            else
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.ApprovedFailed;
                CustomMessageControl.MessageType     = MessageTypes.Error;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(UserContext, SysEventType.INFO, "Approved Data Update Failed",
                                  GlobalCustomResource.ApprovedFailed, true);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Convert the list of OrderDetailsTemp's data to OrderDetailForPrint
        /// </summary>
        /// <param name="targetTable"></param>
        /// <param name="unitofwork"></param>
        /// <returns></returns>
        public OrderForPrint GetAndConverOrderDetails(Entities.Table targetTable, EmployeewsOfLocalPOS unitofwork, EmployeewsOfCloudPOS cloudPosUnitofwork, int printType)
        {
            // get Chairs data from target Table
            var targetChairs = unitofwork.ChairRepository.Get(x => x.TableOwned == targetTable.TableId);

            // get OrderDetailsTemp data from target Table
            List <OrderDetailsTemp> targetOrderDetails = new List <OrderDetailsTemp>();

            foreach (var chair in targetChairs)
            {
                targetOrderDetails.AddRange(unitofwork.OrderDetailsTempRepository.Get(x => x.ChairId == chair.ChairId));
            }

            // convert
            foreach (var orderDetailsTemp in targetOrderDetails)
            {
                if (orderDetailsTemp.IsPrinted == 1 && (DoPrintHelper.Bar_Printing == printType || printType == DoPrintHelper.Kitchen_Printing))
                { // ignore the printed orderDetails is only available when bar printing and kitchen printing
                    continue;
                }
                OrderDetails.Add(new OrderDetailsForPrint()
                {
                    Quan         = orderDetailsTemp.Quan,
                    ProductName  = cloudPosUnitofwork.ProductRepository.Get(p => p.ProductId == orderDetailsTemp.ProductId).First().Name,
                    ProductPrice = cloudPosUnitofwork.ProductRepository.Get(p => p.ProductId == orderDetailsTemp.ProductId).First().Price,

                    ProductId     = orderDetailsTemp.ProductId,
                    ProductType   = cloudPosUnitofwork.ProductRepository.Get(p => p.ProductId == orderDetailsTemp.ProductId).First().Type,
                    ChairNumber   = unitofwork.ChairRepository.Get(c => c.ChairId == orderDetailsTemp.ChairId).First().ChairNumber,
                    Note          = orderDetailsTemp.Note,
                    SelectedStats = orderDetailsTemp.SelectedStats,
                });
            }


            return(this);
        }
Esempio n. 19
0
 public void SaveOrderDetail(OrderDetail od)
 {
     OrderDetails.Add(od);
 }
Esempio n. 20
0
 // DDD Patterns comment:
 // This Order AggregateRoot's method "AddOrderitem()" should be the only way to add Items to the Order. This centralized approach provides consistency to the entire aggregate.
 public void AddOrderItem(string title, int productId, string artist, int quantity, decimal unitPrice)
 {
     OrderDetails.Add(new OrderDetail(title, artist, productId, quantity, unitPrice));
 }
Esempio n. 21
0
        protected void Save_Click(object sender, EventArgs e)
        {
            OrderTransactions orderTransactions = new OrderTransactions();
            var orderDetails  = OrderTransactionsData.FirstOrDefault().orderDetails.Where(x => x.SlNo.Trim() == SlNoKey).ToList();
            var orderDetails1 = OrderTransactionsData.FirstOrDefault().orderDetails.Where(x => x.SlNo.Trim() == SlNoKey).ToList();

            if (orderDetails.Count == 0)
            {
                return;
            }
            var updateOrderDetails = new OrderDetails();

            foreach (var orderdetail in orderDetails)
            {
                //orderdetail.LogisticOrderNumber = ForecastingEditPart.LogistiOrderNumber.Trim();
                orderdetail.SQuantity += ForecastingEditPart.Quantity;
                if (StageType == Constants.BillTrackingType)
                {
                    if (FilterOrder == Constants.PendingOrder && ForecastingEditPart.Quantity == ForecastingEditPart.RemaingQty)
                    {
                        orderdetail.Off = Constants.TRNCompletedOFF;
                    }
                    else
                    {
                        orderdetail.Off = Constants.TRNInProcessOFF;
                    }
                }
                else
                {
                    if (ForecastingEditPart.Quantity == ForecastingEditPart.RemaingQty)
                    {
                        orderdetail.Off = Constants.TRNInProcessOFF;
                    }
                    else
                    {
                        orderdetail.Off = Constants.TRNLogedOFF;
                    }
                }
                if (ForecastingEditPart.CurrentStatus == Constants.OrderingType ||
                    ForecastingEditPart.CurrentStatus == Constants.ChangeStatus ||
                    ForecastingEditPart.CurrentStatus == Constants.AlternativePartNeeded)
                {
                    orderdetail.ShQuantity += ForecastingEditPart.Quantity;
                    if (ForecastingEditPart.CurrentStatus == Constants.ChangeStatus)
                    {
                        orderdetail.BQuantity  += ForecastingEditPart.Quantity;
                        orderdetail.DoQuantity += ForecastingEditPart.Quantity;
                    }
                    orderdetail.LogisticOrderNumber = orderdetail.LogisticOrderNumber.Trim() + "," + ForecastingEditPart.LogistiOrderNumber.Trim();
                }
                updateOrderDetails.Add(orderdetail);
            }
            var insertOrderDeatil = new OrderDetails();

            foreach (var orderdetail in orderDetails1)
            {
                orderdetail.SQuantity           = ForecastingEditPart.CurrentStatus == Constants.AlternativePartNeeded ? ForecastingEditPart.Quantity : 0;
                orderdetail.Quantity            = ForecastingEditPart.Quantity;
                orderdetail.CurrentStatus       = ForecastingEditPart.CurrentStatus;
                orderdetail.LogisticOrderNumber = ForecastingEditPart.LogistiOrderNumber.Trim();
                insertOrderDeatil.Add(orderdetail);
            }
            var sqty = orderDetails.FirstOrDefault().Quantity;
            var qty  = ForecastingEditPart.Quantity;

            orderTransactions.Add(new OrderTransaction
            {
                orderHead          = ForecastingHead.GetData(),
                orderDetails       = insertOrderDeatil,
                updateOrderDeatils = updateOrderDetails,
                Action             = Action,
                DataBaseInfo       = UserContext.DataBaseInfo,
                StageId            = TransactionStageControlId.ActiveStage.Trim(),
                Bu  = UserContext.UserProfile.Bu,
                Off = StageType == Constants.BillTrackingType ? ForecastingEditPart.CurrentStatus == Constants.OrderingType ? Constants.TRNCompletedOFF : Constants.TRNInProcessOFF :
                      qty == ForecastingEditPart.RemaingQty ? Constants.TRNInProcessOFF : Constants.TRNLogedOFF,
                //Off = Constants.TRNInProcessOFF,
                Branch    = UserContext.UserProfile.Branch,
                LogedUser = UserContext.UserId,
                FormType  = FilterOrder == Constants.PendingOrder ? FormType.Pending : FormType.Fresh
            });
            var firstOrDefault = orderTransactions.FirstOrDefault();
            var references     = getReferences();

            if (firstOrDefault != null)
            {
                firstOrDefault.References = references;
            }
            if (_transactionManager.SetTeam(orderTransactions))
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.TeamDataSaved;
                CustomMessageControl.MessageType     = MessageTypes.Success;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(UserContext, SysEventType.INFO, "Team Data Saved",
                                  GlobalCustomResource.TeamDataSaved, true);

                ForecastingEditPart.clearForm();
                // divEdit.Visible = false;
                divEdit.Attributes.Add("style", "display:none");
                ClearReferences();
                fillForm();

                // ScriptManager.RegisterStartupScript(Page, typeof(Page), "openTabFunctionCall", "openTab(1)", true);
            }
            else
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.TeamDataFailed;
                CustomMessageControl.MessageType     = MessageTypes.Error;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(UserContext, SysEventType.INFO, "Team Data Update Failed",
                                  GlobalCustomResource.TeamDataFailed, true);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            decimal x;
            short   y;
            float   z;
            int     r;
            string  str;
            bool    success;

            success = decimal.TryParse(unitPrice.Text.ToString(), out x);
            if (success)
            {
                ordDet.UnitPrice = x;
            }
            else
            {
                System.Windows.MessageBox.Show("Niepoprawna cena jednostkowa");
                return;
            }

            success = short.TryParse(quantity.Text.ToString(), out y);
            if (success)
            {
                ordDet.Quantity = y;
            }
            else
            {
                System.Windows.MessageBox.Show("Niepoprawna ilość porduktów");
                return;
            }

            success = float.TryParse(discount.Text.ToString(), out z);
            if (success)
            {
                ordDet.Discount = z;
            }
            else
            {
                ordDet.Discount = 0;
            }

            str     = order.Text.ToString().Split('-')[0];
            success = Int32.TryParse(str, out r);
            if (success)
            {
                ordDet.OrderID = r;
            }
            else
            {
                System.Windows.MessageBox.Show("Zamówienie jest podane niepoprawnie.");
                return;
            }

            str     = product.Text.ToString().Split('-')[0];
            success = Int32.TryParse(str, out r);
            if (success)
            {
                ordDet.ProductID = r;
            }
            else
            {
                System.Windows.MessageBox.Show("Produkt jest podany niepoprawnie.");
                return;
            }
            using (var db = new Context())
            {
                foreach (var item in db.OrderDetails)
                {
                    if (ordDet.ProductID == item.ProductID && ordDet.OrderID == item.OrderID)
                    {
                        System.Windows.MessageBox.Show("Detal o takich numerach ID już istnieje.");
                        return;
                    }
                }
            }
            ordDet.Add();
            this.Close();
        }
Esempio n. 23
0
 public void AddProduct(Product product, int quantity)
 {
     OrderDetails.Add(new OrderDetail(product, quantity));
 }
Esempio n. 24
0
        public async Task ClearAndFillWithDemoData()
        {
            await OrderDetails.ForEachAsync(od => OrderDetails.Remove(od));

            await Orders.ForEachAsync(o => Orders.Remove(o));

            await Customers.ForEachAsync(c => Customers.Remove(c));

            await Products.ForEachAsync(p => Products.Remove(p));

            var demoCustomers = new[] {
                new Customer()
                {
                    CompanyName = "Corina Air Conditioning", CountryIsoCode = "AT"
                },
                new Customer()
                {
                    CompanyName = "Fernando Engineering", CountryIsoCode = "AT"
                },
                new Customer()
                {
                    CompanyName = "Murakami Plumbing", CountryIsoCode = "CH"
                },
                new Customer()
                {
                    CompanyName = "Naval Metal Construction", CountryIsoCode = "DE"
                }
            };

            Customers.AddRange(demoCustomers);

            var demoProducts = new[] {
                new Product()
                {
                    Description = "Mountain Bike", IsAvailable = true, CategoryCode = "BIKE", PricePerUom = 2500
                },
                new Product()
                {
                    Description = "Road Bike", IsAvailable = true, CategoryCode = "BIKE", PricePerUom = 2000
                },
                new Product()
                {
                    Description = "Skate Board", IsAvailable = true, CategoryCode = "BOARD", PricePerUom = 100
                },
                new Product()
                {
                    Description = "Long Board", IsAvailable = true, CategoryCode = "BOARD", PricePerUom = 250
                },
                new Product()
                {
                    Description = "Scooter", IsAvailable = false, CategoryCode = "OTHERS", PricePerUom = 150
                }
            };

            Products.AddRange(demoProducts);

            var rand = new Random();

            for (var i = 0; i < 100; i++)
            {
                var order = new OrderHeader()
                {
                    OrderDate = new DateTimeOffset(new DateTime(2014, rand.Next(1, 12), rand.Next(1, 28))),
                    Customer  = demoCustomers[rand.Next(demoCustomers.Length - 1)]
                };
                Orders.Add(order);

                for (var j = 0; j < 3; j++)
                {
                    OrderDetails.Add(new OrderDetail()
                    {
                        Order   = order,
                        Product = demoProducts[rand.Next(demoProducts.Length - 1)],
                        Amount  = rand.Next(1, 5)
                    });
                }
            }

            await SaveChangesAsync();
        }
Esempio n. 25
0
 public virtual ActionResult SaveOrderDetail(OrderDetailModel model)
 {
     if (model.OrderDetailId <= 0) //Create News
     {
         SaveOrderDetailToSession(model);
         List <Product> products;
         if (model.ProductIds.FirstOrDefault() == -1 || model.ProductIds.FirstOrDefault() == -2)
         {
             products = _productRepository.Search("").Where(p => p.CategoryId == model.CategoryId).ToList();
         }
         else
         {
             products = _productRepository.Search("").Where(p => model.ProductIds.Contains(p.ProductId)).ToList();
         }
         //if (!model.PrintIncludeImage && !model.PrintWithoutImage && products.Any(p => p.Printable) && model.ProductIds.FirstOrDefault() != -1)
         //{
         //    SetErrorNotification(string.Format("Bạn phải chọn in hình hoặc in không hình cho sản phẩm."));
         //    return RedirectToAction("CreateOrder", "Home", new { area = "", blank = false });
         //}
         //if (string.IsNullOrEmpty(model.FilePathBia) && string.IsNullOrEmpty(model.FilePathRuot) && products.Any(p => p.Printable) && model.ProductIds.FirstOrDefault() != -1)
         //{
         //    SetErrorNotification(string.Format("Bạn chưa up file hình cho sản phẩm."));
         //    return RedirectToAction("CreateOrder", "Home", new { area = "", blank = false });
         //}
         if (model.Amount > 500)
         {
             model.Amount += 5;
         }
         else
         {
             model.Amount += 3;
         }
         Random rnd     = new Random();
         int    groupId = 0;
         if (OrderDetails.Any())
         {
             groupId = OrderDetails.Max(p => p.GroupId);
         }
         foreach (var item in products)
         {
             int orderDetailId = rnd.Next(-9999, -1);
             OrderDetails.Add(new OrderDetailModel
             {
                 Amount            = model.Amount,
                 FilePathBia       = model.FilePathBia,
                 FilePathRuot      = model.FilePathRuot,
                 Note              = model.Note,
                 OrderId           = model.OrderId,
                 ProductId         = item.ProductId,
                 CategoryName      = item.Category.CategoryName,
                 ProductName       = item.ProductName,
                 StorageId         = model.StorageId,
                 OrderDetailId     = orderDetailId,
                 PrintIncludeImage = model.PrintIncludeImage,
                 PrintWithoutImage = model.PrintWithoutImage,
                 Printable         = item.Printable,
                 CategoryId        = model.CategoryId,
                 GroupId           = groupId + 1
             });
         }
         FillCostForOrderDetail(OrderDetails);
     }
     OrderDetailSession = new OrderDetailModel();
     this.SetSuccessNotification(string.Format("{0} đã được thêm vào đơn hàng thành công.", "Sản phẩm"));
     return(RedirectToAction("CreateOrder", "Home", new { area = "", blank = false }));
 }
Esempio n. 26
0
        public async Task FetchOrders()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    OrderDetails.Clear();
                    RequestedOrders.Clear();
                    CancelOrders.Clear();
                    CompleteOrders.Clear();
                    ProductList.Clear();
                    CustomerOrders orders = await this.orderDataService.GetOrderedItemsAsync();

                    if (orders != null)
                    {
                        foreach (var item in orders.Data.CustomerInvoiceData)
                        {
                            OrderDetails.Add(item);
                            if (!string.IsNullOrEmpty(item.OrderStatus))
                            {
                                if (item.OrderStatus.ToLower().Replace(" ", "") == "ontheway" || item.OrderStatus.ToLower().Replace(" ", "") == "packed" ||
                                    item.OrderStatus.ToLower().Replace(" ", "") == "inprogress" || item.OrderStatus.ToLower().Replace(" ", "") == "accepted")
                                {
                                    RequestedOrders.Add(item);
                                }
                                else if (item.OrderStatus.ToLower() == "cancelled" || item.OrderStatus.ToLower() == "rejected")
                                {
                                    CancelOrders.Add(item);
                                }
                                else if (item.OrderStatus.ToLower() == "delivered")
                                {
                                    CompleteOrders.Add(item);
                                }
                            }
                        }

                        foreach (var item in orders.Data.InvocieLineItems)
                        {
                            ProductList.Add(item);
                        }
                    }
                }
                catch (Exception e)
                {
                    try
                    {
                        DependencyService.Get <IToastMessage>().LongTime("Unable to load order list");
                    }
                    catch { }
                }
                finally
                {
                    IsBusy = false;
                }
            }
            else
            {
                try
                {
                    DependencyService.Get <IToastMessage>().LongTime("Check your Internet Connection to reload the list");
                }
                catch { }
                IsBusy = false;
            }
        }