Example #1
1
 public OrderInfo(OrderLine ordLine)
 {
     OrderId = ordLine.OrderID;
     OrderItemId = ordLine.OrderItemID;
     OrderNumber = ordLine.OrderNumber;
     ShipMethod = ordLine.ShipMethod;
 }
 public ActionResult Edit(OrderLine Line)
 {
     ShoppingCart cart = Session["ShoppingCart"] as ShoppingCart;
     cart.OrderLines.FirstOrDefault(x => x.Movie == Line.Movie).Amount = Line.Amount;
     Session["ShoppingCart"] = cart;
     return RedirectToAction("Index");
 }
Example #3
0
    public static void InsertProductToOrder(Product prod)
    {
        if (StateItems.IsInOrderMode)
        {
            Order order = StateItems.CurrentOrder;
            if (order.OrderLines == null)
                order.OrderLines = new List<OrderLine>();
            int count = order.OrderLines.Where(o => o.Product.ProductID == prod.ProductID).Count();
            if (count > 0)
                return;

            OrderLine orderLine = new OrderLine();
            orderLine.ID = new OrderLineId(order, prod);
            orderLine.ItemPrice = prod.Price;
            orderLine.ItemPriceDiscount = new decimal(0.0f);
            orderLine.Quantity = 1;
            //orderLine.Product = prod;
            int taxValue = Int32.Parse(prod.Tax.Value);
            orderLine.Tax = Math.Round((decimal)((float)orderLine.ItemPrice / (1 + 100.0f / taxValue)) * 1, 2);
            orderLine.Total = orderLine.Quantity * (orderLine.ItemPrice - orderLine.ItemPriceDiscount);
            order.OrderLines.Add(orderLine);

            order.TaxAmount += orderLine.Tax;
            order.Total += orderLine.Total;
            order.SubTotal = (order.Total - order.TaxAmount);
        }
    }
Example #4
0
 internal void AddItem(Product product, int quantity)
 {
     var discount = (int)(product.Price * ((double)_discount/100));
     var discountedPrice = product.Price - discount;
     var orderLine = new OrderLine(product.Id, product.Name, product.Price, discountedPrice, quantity);
     RaiseEvent(new ItemAdded(Id, orderLine));
 }
        public void RemoveOrderLine(OrderLine orderLine)
        {
            orderLine = _orderLines.Find(o => o == orderLine);
            if (orderLine == null) return;

            _orderTotal -= orderLine.Total;
            _orderLines.Remove(orderLine);
        }
        public void OrderLinePropertiesSetTest()
        {
            Movie mov = new Movie() { ID = 0, Title = "T**s Galore", Genre = FakeDB.GetInstance().FindGenreByName("Comedy"), ImageURL = null, TrailerURL = null, Price = (59.99), Year = 1993 };
            OrderLine line = new OrderLine(mov, 1);

            Assert.AreEqual(line.Movie, mov);
            Assert.AreEqual(line.Amount,1);
        }
Example #7
0
        public void AddOrderItem(OrderLine objOrdLine)
        {
            if (!HasPackingExceptionItems)
                HasPackingExceptionItems = objOrdLine.Item.PackingException;

            OrderItems.Add(objOrdLine.ProductId + "_" + objOrdLine.OrderItemID,
                           new OrderItem(new OrderInfo(objOrdLine), objOrdLine.Item, objOrdLine.Quantity));
        }
Example #8
0
 public static void AddToCart(UserProfile u, Product p, int count)
 {
     OrderLine ol = new OrderLine();
     ol.Product = p.id;
     ol.productCount = count;
     ol.ShoppingCart1 = u.ShoppingCarts.LastOrDefault();
     DB.OrderLines.Add(ol);
     DB.SaveChanges();
 }
        private static string getProductLayout(OrderLine item)
        {
            string layout = "<table>" + "\r\n" +
                            "<tr><td rowspan='3'><img src='https://webshop.blob.core.windows.net/images/" + item.BasketItem.prod.Image + "'/></td>" + "\r\n" +
                            "<td><strong>Product: </strong>" + item.BasketItem.prod.Naam + "</td></tr>" + "\r\n" +
                            "<tr><td><strong>Aantal: </strong>" + item.BasketItem.Aantal + "</td></tr>" + "\r\n" +
                            "<tr><td><strong>Prijs: </strong> € " + item.TotaalPrijs +"</td></tr><tr><td></td><td></td></table>";

            return layout;
        }
        public void Test_AreEqual_AddOrderLine()
        {
            //Arrange
            var order = new Order(10, 200);
            IOrderLine orderline = new OrderLine(20m);
            order.AddOrderLine(orderline);

            //Assert
            Assert.IsNotNull(order.OrderLines != null);
        }
Example #11
0
        public void Orderline_Properties_Set_Test()
        {
            OrderLine line = new OrderLine();
            var movie = new Movie() { Id = 1, Title = "Smurf" };
            line.Movie = movie;
            line.Amount = 10;

            Assert.AreEqual(line.Movie, movie, "My movie should be the same");
            Assert.AreEqual(line.Amount, 10, "Amount should be 10");
        }
        public void Test_AreEqual_Price()
        {
            //Arrange
            var orderLine = new OrderLine(20.00m);

            //Act
            var expected = 20.00m;
            var actual = orderLine.Price;

            Assert.AreEqual(expected, actual);
        }
Example #13
0
 public void GivenWeHaveABasketForARegularCustomer_WhenAddingItems_ThePriceOfTheBasketShouldNotBeDiscounted(string productName, int itemPrice, int quantity)
 {
     var customerId = Guid.NewGuid();
     var productId = Guid.NewGuid();
     var id = Guid.NewGuid();
     var expectedOrderLine = new OrderLine(productId, productName, itemPrice, itemPrice, quantity);
     Given(new ProductCreated(productId, productName, itemPrice),
         new BasketCreated(id, customerId, 0));
     When(new AddItemToBasket(id, productId, quantity));
     Then(new ItemAdded(id, expectedOrderLine));
 }
        public void Composite_foreign_key_value_is_obtained_from_reference_to_principal()
        {
            var model = BuildModel();

            var principal = new OrderLine { OrderId = 11, ProductId = 21 };
            var dependent = new OrderLineDetail { OrderLine = principal };

            var dependentEntry = CreateContextConfiguration(model).StateManager.GetOrCreateEntry(dependent);

            Assert.Equal(11, CreateValueGenerator().Next(dependentEntry, model.GetEntityType(typeof(OrderLineDetail)).GetProperty("OrderId")));
            Assert.Equal(21, CreateValueGenerator().Next(dependentEntry, model.GetEntityType(typeof(OrderLineDetail)).GetProperty("ProductId")));
        }
        public void Test_AreEqual_Id()
        {
            //Arrange
            var orderLine = new OrderLine(20.00m);
            orderLine.Id = 10;

            //Act
            var actual = orderLine.Id;
            var expected = 10;

            Assert.AreEqual(expected, actual);
        }
        public void Test_AreEqual_Quantity()
        {
            //Arrange
            var orderLine = new OrderLine(20.00m);
            orderLine.Quantity = 15;

            //Act
            var actual = 15;
            var expected = 15;

            //Assert
            Assert.AreEqual(expected, actual);
        }
Example #17
0
 public void GivenWeHaveABasketForAPreferredCustomer_WhenAddingItems_ThePriceOfTheBasketShouldBeDiscounted(string productName, int itemPrice, int quantity, int discountPercentage, int discountedPrice)
 {
     var customerId = Guid.NewGuid();
     var productId = Guid.NewGuid();
     var id = Guid.NewGuid();
     var expectedOrderLine = new OrderLine(productId, productName, itemPrice, discountedPrice, quantity);
     Given(new CustomerCreated(customerId, "John Doe"),
         new CustomerMarkedAsPreferred(customerId, discountPercentage),
         new ProductCreated(productId, productName, itemPrice),
         new BasketCreated(id, customerId, discountPercentage));
     When(new AddItemToBasket(id, productId, quantity));
     Then(new ItemAdded(id, expectedOrderLine));
 }
Example #18
0
        //
        // POST: /Cart/Add
        public ActionResult Add(Product product)
        {
            if (product == null)
            {
               return HttpNotFound();
            }

            OrderLine ol = new OrderLine();

            ol.ProductID = product.ProductID;

            return PartialView(ol);
        }
 public void AddOrder(ShoppingCart Cart, int CustomerID)
 {
     //Add the order
     Order newOrder = new Order() { Customer = new Facade().GetCustomerRepository().GetCustomer(CustomerID), date = DateTime.Now };
     new Facade().GetOrderRepository().Add(newOrder);
     //Add the orderlines
     int OrderID = new Facade().GetOrderRepository().ReadAll().Where(x => x.CustomerId == CustomerID).OrderBy(x => x.date).LastOrDefault().Id;
     List<OrderLine> OrderLines = new List<OrderLine>();
     foreach (OrderLineViewModel Line in Cart.OrderLines)
     {
         OrderLine newLine = new OrderLine() { MovieId = Line.MovieVM.Movie.Id, Amount = Line.Amount, OrderId = OrderID };
         new Facade().GetOrderLineRepository().Add(newLine);
     }
 }
Example #20
0
        public Customer(OrderLine orderLine)
        {
            OrderNumber = orderLine.OrderNumber;
            FirstName = orderLine.FirstName;
            LastName = orderLine.LastName;
            Address = orderLine.Address;
            Address2 = orderLine.Address2;
            City = orderLine.City;
            State = orderLine.State;
            Zip = orderLine.Zip;
            Phone = orderLine.Phone;

            POBox = CheckForPoBox();
        }
Example #21
0
 public void WhenTheUserCheckoutWithAnAmountLargerThan100000_TheOrderNeedsApproval()
 {
     var address = new Address("Valid street");
     var basketId = Guid.NewGuid();
     var orderId = Guid.NewGuid();
     IdGenerator.GenerateGuid = () => orderId;
     var orderLine = new OrderLine(Guid.NewGuid(), "Ball", 100000, 100001, 1);
     Given(new BasketCreated(basketId, Guid.NewGuid(), 0),
         new ItemAdded(basketId, orderLine),
         new BasketCheckedOut(basketId, address));
     When(new MakePayment(basketId, 100001));
     Then(new OrderCreated(orderId, basketId, Helpers.ToFSharpList(new [] {orderLine})),
         new NeedsApproval(orderId));
 }
Example #22
0
        public Order(OrderLine orderLine)
        {
            Account = orderLine.Account;
            OrderNumber = orderLine.OrderNumber;
            FirstOrderItemId = orderLine.OrderItemID;
            OrderId = orderLine.OrderID;
            ShipMethod = orderLine.ShipMethod;
            Gift = orderLine.Gift;

            HasPackingExceptionItems = orderLine.Item.PackingException;

            OrderItems = new SortedList<string, OrderItem>();
            OrderItems.Add(orderLine.ProductId + "_" + orderLine.OrderItemID,
                           new OrderItem(new OrderInfo(orderLine), orderLine.Item, orderLine.Quantity));
        }
        public ActionResult AddToCart(int movieId)
        {
            ShoppingCart cart = Session["ShoppingCart"] as ShoppingCart;
            if (cart == null)
            {
                cart = new ShoppingCart();
            }

            Movie movie = facade.GetMovieGateway().Read(movieId);
            OrderLine line = new OrderLine() { Movie = movie, Amount = 1};
            cart.AddOrderLine(line);

            Session["ShoppingCart"] = cart;
            return Redirect("Index");
        }
            public CreateTest(OrmTestSession db)
            {
                db.CreateTable<OrderLine>();

                var orderLine = db.GetMapping<OrderLine>();
                Assert.AreEqual(4, orderLine.Columns.Count, "OrderLine has 4 columns");

                var l = new OrderLine { Status = OrderLineStatus.Shipped };
                db.Insert(l);

                OrderLine lo = db.Table<OrderLine>().First(x => x.Status == OrderLineStatus.Shipped);
                Assert.AreEqual(lo.Id, l.Id);

                Id = lo.Id;
            }
Example #25
0
    //adds products to customers
    public static Customer addItemtoCart(List<Product> prodIn, Customer custIn, int prodId, int qtyIn)
    {
        try
        {

            foreach (Product item in prodIn)
            {
                if (item.ProdID == prodId)
                {

                    bool alreadyOrdered = false;
                    int foundWhere = 0;
                    for (int i = 0; i < custIn.Orders[0].OrderLines.Count; i++)
                    {

                        if (custIn.Orders[0].OrderLines[i].ProdID == Convert.ToInt16(prodId))
                        {
                            foundWhere = i;
                            alreadyOrdered = true;
                        }//end if
                    }//end for

                    if (alreadyOrdered == true)//update the QTY
                    {
                        custIn.Orders[0].OrderLines[foundWhere].Quantity += qtyIn;
                    }
                    else
                    {
                        OrderLine orderLine = new OrderLine();
                        orderLine.Product = item;
                        orderLine.Quantity = qtyIn;
                        custIn.Orders[0].OrderLines.Add(orderLine);
                    }
                }
            }

        }
        catch (Exception)
        {
        }
        return custIn;
    }
        public List<OrderLine> makeOrderLineList(List<Basket> bask, string userId)
        {
            //orderline lijst aanmaken om die dan te gaan opslaan in onze tabel orders in de database
            List<OrderLine> OrderLines = new List<OrderLine>();

            foreach (Basket bas in bask)
            {
                OrderLine orderline = new OrderLine()
                {
                    BasketID = bas.ID,
                    BasketItem = bas,
                    TotaalPrijs = Calculate.TotaalPrijs(bas),
                    UserID = userId
                };

                OrderLines.Add(orderline);
            }

            return OrderLines;
        }
Example #27
0
        public void SaveOrder()
        {
            string shippingAddress = null, 
                   billingAddress = null;
            Product msdnSubscription = null;
            Customer customer = new Customer();
Order order = new Order(customer, shippingAddress, billingAddress,
            ShippingMethod.UPS);//new order
OrderLine line = new OrderLine(order, msdnSubscription, 1);//new order line
order.OrderLines.Add(line);//add order line to order

//create a session provide, provide the current database session
ISessionProvider sessionProvider = new SessionProvider();
//handles dispatching of the order to other systems
IOrdersDispatcher ordersDispatcher = new OrdersDispatcher();
//order repository contains specialized behavior that execute when
//saving an order
OrderRepository orderRepository = new OrderRepository(
        sessionProvider, ordersDispatcher);
//save the order to the database
orderRepository.Save(order);

        }
        public ActionResult Add(int bookId)
        {
            BookShopEntities db = new BookShopEntities();
            var shoppingCart = GetShoppingCart();

            var existingLine = shoppingCart.Lines.SingleOrDefault(l => l.Book.Id == bookId);
            if (existingLine != null)
            {
                existingLine.Quantity++;
            }
            else
            {
                var book = db.Books.First(b => b.Id == bookId);

                OrderLine newOrderLine = new OrderLine();
                newOrderLine.Book = book;
                newOrderLine.Quantity = 1;
                shoppingCart.AddLineItem(newOrderLine);
            }

            ViewData.Model = shoppingCart;
            return RedirectToAction("Index");
        }
Example #29
0
 public void Update(OrderLine orderLine)
 {
     _db.OrderLine.Update(orderLine);
 }
    /*--------------- Function Area-----------------*/

    /*
     * Function for saving changed values
     * Author:Shahriar
     * Date:12-7-07
     */
    private bool SaveInvoiceDetails(string invoiceId)
    {
        int    num      = grdInvoiceLine.Rows.Count + 1;
        string errorMsg = "";

        Invoice objInvoice = new Facade().GetInvoiceByInvoiceId(invoiceId);

        if (objInvoice != null)
        {
            objInvoice.Customerbtwnr = txtCustBTWValue.Text.Trim();
            objInvoice.Housenr       = txtHouseNr.Text.Trim();
            objInvoice.address       = txtAddress.Text.Trim();
            objInvoice.Postcode      = txtPostCode.Text.Trim();
            objInvoice.Residence     = txtResidence.Text.Trim();
            objInvoice.Country       = ddlCountry.SelectedValue.ToString();
        }

        System.Globalization.CultureInfo        enUS = new System.Globalization.CultureInfo("en-US", true);
        System.Globalization.DateTimeFormatInfo dtfi = new System.Globalization.DateTimeFormatInfo();
        dtfi.ShortDatePattern = "dd-MM-yyyy";
        dtfi.DateSeparator    = "-";

        DateTime dtIn = Convert.ToDateTime(txtInvoiceDate.Text.Trim(), dtfi);

        objInvoice.Invoicedate   = DateTime.Parse(dtIn.ToString("yyyy-MM-dd"));
        objInvoice.Invoicestatus = drpStatus.SelectedValue.ToString();

        List <OrderLine> orderLines = new List <OrderLine>();

        foreach (GridViewRow row in grdInvoiceLine.Rows)
        {
            OrderLine orderLine = new OrderLine();
            Label     lblOrder  = (Label)row.Cells[0].FindControl("lblOrder");
            string    order     = lblOrder.Text;
            orderLine.Orderid = Int32.Parse(order.ToString());
            Label  lblArticleID = (Label)row.Cells[0].FindControl("lblArticleID");
            string article      = lblArticleID.Text;
            orderLine.Articlecode = article;
            TextBox intCtrQuanity = (TextBox)row.Cells[2].FindControl("intCtrQuanity");
            if (bool.Parse(ViewState["isCredited"].ToString()).Equals(false))
            {
                orderLine.Quantity = Convert.ToInt32(intCtrQuanity.Text.Replace(',', '.'));
            }
            else
            {
                orderLine.Creditedquantity = Convert.ToInt32(intCtrQuanity.Text.Replace(',', '.'));
            }
            TextBox intCtrUnitPrice = (TextBox)row.Cells[4].FindControl("intCtrUnitPrice");
            orderLine.Unitprice = Convert.ToDouble(intCtrUnitPrice.Text.Replace(',', '.'));
            TextBox intCtrVat = (TextBox)row.Cells[4].FindControl("intCtrVat");
            orderLine.Vatpc = Convert.ToDouble(intCtrVat.Text.Replace(',', '.'));
            //DecimalControl intCtrDiscount= (DecimalControl)row.Cells[4].FindControl("intCtrDiscount");

            orderLine.Unitprice = double.Parse(intCtrUnitPrice.Text.Replace(',', '.'));
            orderLine.Vatpc     = double.Parse(intCtrVat.Text.Replace(',', '.'));

            orderLines.Add(orderLine);
        }
        bool b = new Facade().UpdateInvoice(objInvoice, orderLines, bool.Parse(ViewState["isCredited"].ToString()), num, ref errorMsg);

        if (b == false)
        {
            if (errorMsg.Contains("23514"))
            {
                errorMsg = "Credited quantity cannot be greater than Ordered quantity";
            }
            lblErrorMsg.Text = errorMsg;
        }
        return(b);
    }
Example #31
0
 /// <summary>
 /// Creator: Dalton Reierson
 /// Created: 2020/04/30
 /// Approver:
 /// Approver:
 ///
 /// no argument constructor
 /// </summary>
 ///
 /// <remarks>
 /// Updated By:
 /// Updated:
 /// Update:
 /// </remarks>
 public UpdateOrderLine()
 {
     InitializeComponent();
     _orderLineManager = new OrderLineManager();
     _orderLine        = new OrderLine();
 }
 public ActionResult Edit(OrderLine orderLine)
 {
     return(View(orderLine));
 }
Example #33
0
        public void OrderLineDetailCrudTest()
        {
            var context = new Container(new Uri("http://localhost:5588/odata/"));

            var item = new Product()
            {
                Key  = "TestProduct" + Guid.NewGuid(),
                Name = "TestProduct",
                Type = "REGULAR"
            };

            context.AddToProducts(item);
            context.SaveChanges();
            var savedItem = context.Products.Where(u => u.Key == item.Key).Single();

            var location = new Location
            {
                Key    = "TestLocation" + Guid.NewGuid(),
                Name   = "TestLocation",
                Type   = "WAREHOUSE",
                UnitId = Guid.NewGuid()
            };

            context.AddToLocations(location);
            context.SaveChanges();
            var savedLocation = context.Locations.Where(l => l.Key == location.Key).Single();

            var orderLine = new OrderLine
            {
                Id         = Guid.NewGuid(),
                BasePrice  = .1f,
                BaseQty    = .1f,
                Price      = .1f,
                Priority   = 1,
                Qty        = .1f,
                Amount     = 10,
                BaseAmount = 10
            };

            context.AddToOrderLines(orderLine);
            context.SaveChanges();
            var savedOrderLine = context.OrderLines.Where(ol => ol.Id == orderLine.Id).Single();

            var uom = new Uom
            {
                Key  = "TestUom" + Guid.NewGuid(),
                Name = "TestUom"
            };

            context.AddToUoms(uom);
            context.SaveChanges();
            var savedUom = context.Uoms.Where(u => u.Key == uom.Key).Single();

            var order = new Order
            {
                Id            = Guid.NewGuid(),
                Amount        = 10,
                BaseAmount    = 10,
                CurrencyId    = Guid.NewGuid(),
                CustomerId    = Guid.NewGuid(),
                Date          = new DateTime(2000, 1, 1),
                DestinationId = Guid.NewGuid(),
                DueDate       = new DateTime(2001, 1, 1),
                LinesCount    = 5,
                Number        = "SO001",
                SourceId      = Guid.NewGuid(),
                Type          = "SO"
            };

            context.AddToOrders(order);
            context.SaveChanges();
            var savedOrder = context.Orders.Where(o => o.Id == order.Id).Single();

            var orderLineDetail = new OrderLineDetail
            {
                BaseQty     = .1f,
                Priority    = 1,
                Qty         = .1f,
                Number      = "SO001",
                ItemId      = savedItem.Id,
                LocationId  = savedLocation.Id,
                OrderLineId = savedOrderLine.Id,
                UomId       = savedUom.Id,
                OrderId     = order.Id
            };

            context.AddToOrderLineDetails(orderLineDetail);

            var response = context.SaveChanges();

            foreach (ChangeOperationResponse change in response)
            {
                var descriptor = change.Descriptor as EntityDescriptor;
                var entity     = descriptor.Entity as OrderLineDetail;

                entity.Number = "SO002";
                context.UpdateObject(entity);
                context.SaveChanges(SaveChangesOptions.ReplaceOnUpdate);

                var savedEntity         = context.OrderLineDetails.Where(r => r.Id == entity.Id).Single();
                var referencedItem      = context.OrderLineDetails.Where(r => r.Id == entity.Id).Select(r => r.Item).Single();
                var referencedLocation  = context.OrderLineDetails.Where(r => r.Id == entity.Id).Select(r => r.Location).Single();
                var referencedOrderLine = context.OrderLineDetails.Where(r => r.Id == entity.Id).Select(r => r.OrderLine).Single();
                var referencedUom       = context.OrderLineDetails.Where(r => r.Id == entity.Id).Select(r => r.Uom).Single();
                var referencedOrder     = context.OrderLineDetails.Where(r => r.Id == entity.Id).Select(r => r.Order).Single();

                context.DeleteObject(savedItem);
                context.DeleteObject(savedLocation);
                context.DeleteObject(savedOrder);
                context.DeleteObject(savedOrderLine);
                context.DeleteObject(savedUom);
                context.DeleteObject(entity);
                var deleteResponses = context.SaveChanges();

                Assert.IsNotNull(savedEntity);
                Assert.AreEqual(savedEntity.Number, entity.Number);
                Assert.AreEqual(referencedItem.Key, item.Key);
                Assert.AreEqual(referencedLocation.Key, location.Key);
                Assert.AreEqual(referencedOrderLine.Id, orderLine.Id);
                Assert.AreEqual(referencedUom.Key, referencedUom.Key);
                Assert.AreEqual(referencedOrder.Id, order.Id);
                Assert.IsNotNull(deleteResponses);
            }

            Assert.IsNotNull(response);
        }
Example #34
0
 public ActionResult OrderRow(OrderLine orderLine)
 {
     return(PartialView(orderLine));
 }
Example #35
0
 public void SaveOrderline(OrderLine finalordln)
 {
 }
Example #36
0
        public void LoadFromFreight(Freight frg)
        {
            UnloadFreight();
            LoadOrderLines(false);

            if (frg.FreightSortingMaterial.Count > 0)
            {
                foreach (FreightSortingMaterial fsm in frg.FreightSortingMaterial)
                {
                    OrderLine ol = new OrderLine();

                    ol.Amount      = fsm.Weight;
                    ol.Material    = fsm.Material;
                    ol.Description = fsm.Description;
                    if (frg.FreightDirection == "To warehouse")
                    {
                        ol.PricePerUnit = fsm.Material.PurchasePrice;
                    }
                    else
                    {
                        ol.PricePerUnit = fsm.Material.SalesPrice;
                    }
                    ol.RecalcTotals();

                    // check for pmv
                    if (frg.FreightWeighing.Count > 0)
                    {
                        foreach (FreightWeighing fw in frg.FreightWeighing)
                        {
                            foreach (FreightWeighingMaterial fwm in fw.FreightWeighingMaterial)
                            {
                                ol.Comments = fwm.Description; //pmv, only from the first line
                                break;
                            }
                            break;
                        }
                    }

                    OrderLines.Add(ol);
                }
            }
            else if (frg.FreightWeighing.Count > 0)
            {
                foreach (FreightWeighing fw in frg.FreightWeighing)
                {
                    foreach (FreightWeighingMaterial fwm in fw.FreightWeighingMaterial)
                    {
                        OrderLine ol = new OrderLine();

                        ol.Amount      = fwm.NetWeight;
                        ol.Material    = fwm.Material;
                        ol.Description = fwm.Material.Description;
                        ol.Comments    = fwm.Description; //pmv
                        if (frg.FreightDirection == "To warehouse")
                        {
                            ol.PricePerUnit = fwm.Material.PurchasePrice;
                        }
                        else
                        {
                            ol.PricePerUnit = fwm.Material.SalesPrice;
                        }
                        ol.RecalcTotals();

                        OrderLines.Add(ol);
                    }
                }
            }

            SaveOrderLines();
        }
        public async Task <IHttpActionResult> Put(int id, OrderLine model)
        {
            await _irepo.Put(id, model);

            return(Ok(model));
        }
Example #38
0
 public OrderLineEventArgs(OrderLine line)
 {
     this.Line = line;
 }
Example #39
0
        public void UpdateOrderRemoveDeliveryDateThrowsException()
        {
            var user = new PasswordUser
            {
                Id          = 1,
                FirstName   = "Bent",
                LastName    = "Nielsen",
                Email       = "*****@*****.**",
                PhoneNumber = "12345678",
                Country     = "Denmark",
                Street      = "H.C.Andersen gade 12",
                ZipCode     = "5000",
                Username    = "******",
                Password    = "******"
            };

            var cover = new Cover
            {
                Color       = "blue",
                Material    = "plastic",
                TypeOfBrand = "Apple",
                TypeOfModel = "iPhone6",
                Stock       = 10,
                Price       = 1234,
                Name        = "PanserProof"
            };

            var ol = new OrderLine
            {
                Product         = cover,
                ProductId       = cover.Id,
                Qty             = 2,
                PriceWhenBought = cover.Price
            };

            var order = new Order
            {
                User         = user,
                DeliveryDate = DateTime.Now,
                OrderDate    = DateTime.Now,
                OrderLines   = new List <OrderLine>
                {
                    ol,
                    new OrderLine
                    {
                        Product         = cover,
                        ProductId       = cover.Id,
                        Qty             = 2,
                        PriceWhenBought = cover.Price
                    }
                }
            };


            var userRepo = new Mock <IUserRepository>();

            userRepo.Setup(x => x.CreateUser(user)).Returns(user);

            var orderRepo = new Mock <IOrderRepository>();

            orderRepo.Setup(x => x.CreateOrder(order)).Returns(order);

            var updatedOrder = new Order
            {
                User       = user,
                OrderDate  = DateTime.Now,
                OrderLines = new List <OrderLine>
                {
                    ol,
                    new OrderLine
                    {
                        Product         = cover,
                        ProductId       = cover.Id,
                        Qty             = 3,
                        PriceWhenBought = cover.Price
                    }
                }
            };

            order = updatedOrder;

            IOrderService service = new OrderService(orderRepo.Object, userRepo.Object);

            Exception ex = Assert.Throws <InvalidDataException>(() => service.UpdateOrder(order));

            Assert.Equal("Must have a Delivery Date", ex.Message);
        }
Example #40
0
 public IHttpActionResult Post(int orderId, OrderLine orderLine)
 {
     orderLine.OrderId = orderId;
     return(Created(orderLine));
 }
Example #41
0
 public virtual void AddOrderLine(OrderLine orderLine)
 {
     if (!_orderLines.Contains(orderLine))
     {
         orderLine.Order = this;
         _orderLines.Add(orderLine);
     }
 }
Example #42
0
 public BookOrderBuilder WithLine(OrderLine line)
 {
     _orderLines.Add(line);
     return(this);
 }
Example #43
0
 public OrderlineInfo(OrderLine initialordln)
 {
     ordln = initialordln;
     LoadOrderline(ordln);
 }
Example #44
0
        public void CanProjectWithWrappedParameterAndLet()
        {
            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    session.Store(new Order
                    {
                        Lines = new List <OrderLine>
                        {
                            new OrderLine
                            {
                                ProductName  = "Coffee",
                                PricePerUnit = 15,
                                Quantity     = 2
                            },
                            new OrderLine
                            {
                                ProductName  = "Milk",
                                PricePerUnit = 7,
                                Quantity     = 10
                            }
                        }
                    });

                    session.Store(new Company
                    {
                        Name = "HR"
                    }, "companies/1");

                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    var line = new OrderLine
                    {
                        PricePerUnit = 15,
                        ProductName  = "Coffee",
                        Discount     = (decimal)0.25
                    };
                    var myOrder = new Order
                    {
                        Company = "companies/1"
                    };

                    var query = from o in session.Query <Order>()
                                let totalSpentOnOrder = (Func <Order, decimal>)(order => order.Lines.Sum(x => x.PricePerUnit * x.Quantity * (1 - line.Discount)))
                                                        select new
                    {
                        Sum         = totalSpentOnOrder(o),
                        Any         = o.Lines.Any(x => x.ProductName == line.ProductName),
                        NestedQuery = o.Lines.Where(x => x.PricePerUnit < line.PricePerUnit).Select(y => y.ProductName).ToList(),
                        Company     = RavenQuery.Load <Company>(myOrder.Company).Name,
                    };

                    RavenTestHelper.AssertEqualRespectingNewLines(
                        @"declare function output(o, $p0, $p1, $p2, $p3) {
	var totalSpentOnOrder = function(order){return order.Lines.map(function(x){return x.PricePerUnit*x.Quantity*(1-$p0);}).reduce(function(a, b) { return a + b; }, 0);};
	return { Sum : totalSpentOnOrder(o), Any : o.Lines.some(function(x){return x.ProductName===$p1;}), NestedQuery : o.Lines.filter(function(x){return x.PricePerUnit<$p2;}).map(function(y){return y.ProductName;}), Company : load($p3).Name };
}
from 'Orders' as o select output(o, $p0, $p1, $p2, $p3)", query.ToString());

                    var result = query.ToList();

                    Assert.Equal(1, result.Count);

                    Assert.Equal(75, result[0].Sum);
                    Assert.True(result[0].Any);
                    Assert.Equal(1, result[0].NestedQuery.Count);
                    Assert.Equal("Milk", result[0].NestedQuery[0]);
                    Assert.Equal("HR", result[0].Company);
                }
            }
        }
Example #45
0
 private void SaveNewOrder(string name, string phone1, int dir, int workType,
                           int subj, decimal price, decimal prepayment, int source)
 {
     using (StudentuConteiner db = new StudentuConteiner())
     {
         try
         {
             OrderLine Order = new OrderLine();
             Persone = new Persone()
             {
                 Name = name
             };
             Contacts Contacts = new Contacts()
             {
                 Phone1 = phone1
             };
             Order.Direction = db.Directions.Find(new Direction()
             {
                 DirectionId = dir
             }.DirectionId);
             Order.Client = new Client()
             {
                 Persone = Persone
             };
             Order.WorkType = db.WorkTypes.Find(new WorkType()
             {
                 WorkTypeId = workType
             }.WorkTypeId);
             Order.Dates = new Dates()
             {
                 DateOfReception = DateTime.Now,
                 DeadLine        = DateTime.Now.AddDays(5),
                 AuthorDeadLine  = DateTime.Now.AddDays(4)
             };
             Order.Subject = db.Subjects.Find(new Subject()
             {
                 SubjectId = subj
             }.SubjectId);
             Order.Money = new Money()
             {
                 Price = price, Prepayment = prepayment
             };
             Order.Status = db.Statuses.Find(new Status()
             {
                 StatusId = 2
             }.StatusId);
             Order.Source = db.Sources.Find(new Source()
             {
                 SourceId = source
             }.SourceId);
             Order.User = db.Users.Where(e => e.UserId == Usver.UserId).FirstOrDefault();
             db.Orderlines.Add(Order);
             db.SaveChanges();
         }
         catch (ArgumentNullException ex)
         {
             dialogService.ShowMessage(ex.Message);
         }
         catch (OverflowException ex)
         {
             dialogService.ShowMessage(ex.Message);
         }
         catch (System.Data.SqlClient.SqlException ex)
         {
             dialogService.ShowMessage(ex.Message);
         }
         catch (System.Data.Entity.Core.EntityCommandExecutionException ex)
         {
             dialogService.ShowMessage(ex.Message);
         }
         catch (System.Data.Entity.Core.EntityException ex)
         {
             dialogService.ShowMessage(ex.Message);
         }
     }
 }
Example #46
0
 protected bool Equals(OrderLine other)
 {
     return(OrderId == other.OrderId &&
            ProductId == other.ProductId);
 }
 public RedirectToRouteResult Edit_POST(OrderLine orderLine)
 {
     _orderService.Save(orderLine);
     return(RedirectToAction("Edit", "Order", new { id = orderLine.Order.Id }));
 }
Example #48
0
        static void CreateOrder(string id)
        {
            Order order = new Order();

            order.id = id;

            OrderAddressInfo address1 = new OrderAddressInfo();

            address1.Address1 = "testing ship";
            address1.Address2 = "testing";
            address1.City     = "Narnia";
            address1.Country  = "Atlantis";
            address1.Email    = "*****@*****.**";
            address1.Name     = new OrderAddressInfoName()
            {
                First = "Romulo Bentancourt", Full = "testing", Last = "testing"
            };
            address1.Phone = "555*666-beast";
            address1.State = "MA";
            address1.type  = "ship";
            address1.Zip   = 01844;

            OrderAddressInfo address2 = new OrderAddressInfo();

            address2.Address1 = "testing bill";
            address2.Address2 = "testing";
            address2.City     = "Narnia";
            address2.Country  = "Atlantis";
            address2.Email    = "*****@*****.**";
            address2.Name     = new OrderAddressInfoName()
            {
                First = "Romulo Bentancourt", Full = "testing", Last = "testing"
            };
            address2.Phone = "555*666-beast";
            address2.State = "MA";
            address2.type  = "bill";
            address2.Zip   = 01844;

            order.AddressInfo = new OrderAddressInfo[] { address1, address2 };

            OrderItem item = new OrderItem();

            item.Code        = "10061-10-M";
            item.Description = "CASH MONEY HOE";
            item.Id          = 6666666;
            item.Quantity    = 10;
            item.UnitPrice   = 100;

            order.Item = new OrderItem[] { item };

            OrderLine orderLine = new OrderLine();

            orderLine.name  = "testing";
            orderLine.type  = "type";
            orderLine.Value = 1000;


            order.Total = new OrderLine[] { orderLine };


            StringWriter stringWriter = new StringWriter();

            XmlSerializer serializer = new XmlSerializer(typeof(Order));

            serializer.Serialize(stringWriter, order);


            using (berkeleyEntities dataContext = new berkeleyEntities())
            {
                Exchange exchange = new Exchange();
                exchange.Data          = stringWriter.ToString();
                exchange.Comment       = "testing";
                exchange.DateCreated   = DateTime.UtcNow;
                exchange.ProcessorCode = "YahooStore";
                exchange.Status        = 0;
                exchange.LastUpdated   = DateTime.UtcNow;

                dataContext.Exchanges.AddObject(exchange);

                dataContext.SaveChanges();
            }
        }
Example #49
0
        private void ProcessSubscription(IUnitOfWork unitOfWork, CustomerOrder customerOrder, OrderLine orderLine)
        {
            ProductSubscriptionDto productSubscriptionDto = this.GetProductSubscriptionDto(orderLine);
            Subscription           subscription           = this.GetSubscription(customerOrder, orderLine, productSubscriptionDto);

            unitOfWork.GetRepository <Subscription>().Insert(subscription);
            Dictionary <Guid, PricingServiceParameter> dictionary = new Dictionary <Guid, PricingServiceParameter>();

            foreach (SubscriptionProduct subscriptionProduct in (IEnumerable <SubscriptionProduct>)orderLine.Product.SubscriptionProducts)
            {
                PricingServiceParameter serviceParameter = new PricingServiceParameter(subscriptionProduct.Product.Id)
                {
                    Product    = subscriptionProduct.Product,
                    QtyOrdered = subscriptionProduct.QtyOrdered * orderLine.QtyOrdered
                };
                dictionary.Add(subscriptionProduct.Product.Id, serviceParameter);
            }
            GetProductPricingResult productPricing = this.pricingPipeline.GetProductPricing(new GetProductPricingParameter(true)
            {
                PricingServiceParameters = (IDictionary <Guid, PricingServiceParameter>)dictionary
            });

            PipelineHelper.VerifyResults((PipeResultBase)productPricing);
            foreach (SubscriptionProduct subscriptionProduct1 in (IEnumerable <SubscriptionProduct>)orderLine.Product.SubscriptionProducts)
            {
                SubscriptionProduct subscriptionProduct = subscriptionProduct1;
                SubscriptionLine    subscriptionLine    = new SubscriptionLine()
                {
                    Product    = unitOfWork.GetRepository <Product>().Get(subscriptionProduct.Product.Id),
                    QtyOrdered = subscriptionProduct.QtyOrdered * orderLine.QtyOrdered
                };
                ProductPriceDto productPriceDto = productPricing.ProductPriceDtos.First <KeyValuePair <Guid, ProductPriceDto> >((Func <KeyValuePair <Guid, ProductPriceDto>, bool>)(o => o.Key == subscriptionProduct.Product.Id)).Value;
                subscriptionLine.Price = productPriceDto.UnitRegularPrice;
                subscription.SubscriptionLines.Add(subscriptionLine);
                //if (subscription.IncludeInInitialOrder)
                //{
                //    OrderLine orderLine1 = new OrderLine()
                //    {
                //        Description = subscriptionLine.Product.ErpDescription,
                //        UnitListPrice = productPriceDto.UnitListPrice,
                //        UnitRegularPrice = productPriceDto.UnitRegularPrice,
                //        UnitNetPrice = subscription.FixedPrice ? subscriptionLine.Price : productPriceDto.UnitNetPrice
                //    };
                //    this.orderLineUtilities.SetProduct(orderLine1, subscriptionLine.Product);
                //    this.orderLineUtilities.SetQtyOrdered(orderLine1, subscriptionLine.QtyOrdered);
                //    PipelineHelper.VerifyResults((PipeResultBase)this.cartPipeline.AddCartLine(new Insite.Cart.Services.Pipelines.Parameters.AddCartLineParameter()
                //    {
                //        Cart = customerOrder,
                //        CartLine = orderLine1
                //    }));
                //}
            }
            if (!subscription.IncludeInInitialOrder)
            {
                return;
            }
            subscription.CustomerOrders.Add(customerOrder);
        }
Example #50
0
 public void RemoveOrderLine(OrderLine orderLine)
 {
     GetOrderLines().Remove(orderLine);
 }
Example #51
0
 private bool ContainsOrderLine(OrderLine line)
 {
     return(this.GetOrderLine(line.Id) != null);
 }
Example #52
0
 public void Insert(OrderLine orderLine)
 {
     _db.OrderLine.Add(orderLine);
 }
Example #53
0
        public SalesOrderListviewDetail(SalesOrderDB item)
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);

            //    App.orderLineList = item.order_line;


            Cus.Text = item.customer;
            CD.Text  = item.DateOrder;
            PT.Text  = item.payment_term;
            SP.Text  = item.sales_person;
            ST.Text  = item.sales_team;
            CR.Text  = item.customer_reference;
            FP.Text  = item.fiscal_position;

            List <OrderLine> or_linelistdb = new List <OrderLine>();


            var json_orderline = JsonConvert.SerializeObject(item.order_line);

            String convertstring = json_orderline.ToString();

            //  "\"[{\\\"customer_lead\\\":\\\"0\\\",\\\"price_unit\\\":\\\"10000\\\",\\\"product_uom_qty\\\":\\\"10\\\",\\\"price_subtotal\\\":\\\"100000\\\",\\\"taxes\\\":[],\\\"product_name\\\":\\\"Floordeck 1000x060 MM\\\"},{\\\"customer_lead\\\":\\\"0\\\",\\\"price_unit\\\":\\\"1\\\",\\\"product_uom_qty\\\":\\\"1\\\",\\\"price_subtotal\\\":\\\"1\\\",\\\"taxes\\\":[\\\"Sales Tax N/A SRCA-S\\\"],\\\"product_name\\\":\\\"Floordeck 1000x060 MM\\\"}]\""

            String finstring = convertstring.Replace("\\", "");

            finstring = finstring.Substring(1);

            finstring = finstring.Remove(finstring.Length - 1);

            JArray stringres = JsonConvert.DeserializeObject <JArray>(finstring);

            //  OrderLine stringres = JsonConvert.DeserializeObject<OrderLine>(json_orderline)

            int    cus_lead  = 0;
            string prod_name = "";



            foreach (JObject obj in stringres)
            {
                OrderLine or_line = new OrderLine();


                or_line.product_name    = obj["product_name"].ToString();
                or_line.product_uom_qty = obj["product_uom_qty"].ToString();
                or_line.price_subtotal  = obj["price_subtotal"].ToString();
                try
                {
                    or_line.tax_names = obj["tax_names"].ToString();
                }
                catch
                {
                    or_line.tax_names = "";
                }

                try
                {
                    or_line.discount = obj["discount"].ToString();
                }

                catch
                {
                    or_line.discount = "";
                }

                or_linelistdb.Add(or_line);
            }



            orderListview.ItemsSource = or_linelistdb;


            //var backImgRecognizer = new TapGestureRecognizer();
            //backImgRecognizer.Tapped += async (s, e) => {
            //    // handle the tap

            //    var currentpage = new LoadingAlert();
            //    await PopupNavigation.PushAsync(currentpage);

            //    // Navigation.PopAllPopupAsync();
            //    App.Current.MainPage = new MasterPage(new CrmTabbedPage());
            //    //  orderListview.ItemsSource = null;
            //    Loadingalertcall();

            //};
            //backImg.GestureRecognizers.Add(backImgRecognizer);
        }
Example #54
0
 public IHttpActionResult Put(int orderId, int lineId, OrderLine orderLine)
 {
     orderLine.OrderId = orderId;
     orderLine.ID      = lineId;
     return(Updated(orderLine));
 }
Example #55
0
        public ActionResult Import(HttpPostedFileBase excelfile)
        {
            if (excelfile.FileName.EndsWith("xls") || excelfile.FileName.EndsWith("xlsx") ||
                excelfile.FileName.EndsWith("csv"))
            {
                string path = Server.MapPath("~/Content/" + excelfile.FileName);
                excelfile.SaveAs(path);
                // Read data from excel file

                Excel.Application application = null;
                Excel.Workbook    workbook    = null;
                Excel.Worksheet   worksheet   = null;
                Excel.Range       range       = null;
                List <OrderLine>  products    = new List <OrderLine>();
                try
                {
                    application = new Excel.Application();
                    workbook    = application.Workbooks.Open(path);
                    worksheet   = workbook.ActiveSheet;
                    range       = worksheet.UsedRange;

                    for (int i = 2; i <= range.Rows.Count; i++)
                    {
                        var product = new OrderLine();
                        for (int j = 1; j <= range.Columns.Count; j++)
                        {
                            //write the value to the console
                            if (range.Cells[i, j] != null && range.Cells[i, j].Value2 != null)
                            {
                                if (j == 1)
                                {
                                    product.ProductCode = range.Cells[i, j].Value2;
                                }
                                else if (j == 2)
                                {
                                    product.Quantity = (int)range.Cells[i, j].Value2;
                                }
                                else if (j == 3)
                                {
                                    product.UnitPrice = Convert.ToDouble(range.Cells[i, j].Value2.ToString());
                                }
                            }
                        }

                        product.StokQuantity = GetStockInformationByProductCode(product.ProductCode);
                        product.TotalPrice   = product.UnitPrice * product.Quantity;
                        var(description, englishDescription) = GetProductDescriptionByProductCode(product.ProductCode);
                        product.ProductDescription           = description;
                        product.ProductEnglishDescription    = englishDescription;
                        products.Add(product);
                    }
                }
                finally
                {
                    workbook.Close(0);
                    application.Quit();

                    if (range != null)
                    {
                        Marshal.ReleaseComObject(range);
                    }
                    if (worksheet != null)
                    {
                        Marshal.ReleaseComObject(worksheet);
                    }
                    if (workbook != null)
                    {
                        Marshal.ReleaseComObject(workbook);
                    }
                    if (application != null)
                    {
                        Marshal.ReleaseComObject(application);
                    }
                }
                return(new JsonResult
                {
                    Data = products,
                    ContentType = "application/json",
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                    MaxJsonLength = Int32.MaxValue
                });
            }
            return(new JsonResult());
        }
Example #56
0
    private bool SaveUpdate()
    {
        orderID = Request.Params["order"];
        int num_order = grdOrderLine.Rows.Count + 3;

        OrderDTO objOrder = new Facade().GetOrderByOrderId(Int32.Parse(orderID));

        if (objOrder != null)
        {
            objOrder.Dhousenr   = txtHousenr.Text.Trim();
            objOrder.Daddress   = txtAddress.Text.Trim();
            objOrder.Dpostcode  = txtPostCode.Text.Trim();
            objOrder.Dresidence = txtResidence.Text.Trim();
            objOrder.Dcountry   = ddlCountry.SelectedValue.Trim();
            objOrder.Orderdate  = DateTime.Parse(ADate.Text.ToString());
            objOrder.Remarks    = txtRemarks.Text.Trim();
            objOrder.Orderid    = Int32.Parse(orderID);
        }

        Customer objCustomer = new Facade().GetCustomerByCustomerId(Int32.Parse(txtHideID.Value.ToString().Trim()));


        if (objCustomer != null)
        {
            objCustomer.Dfirstname   = txtFirstName.Text.Trim();
            objCustomer.Dmiddlename  = txtMiddleName.Text.Trim();
            objCustomer.Dlastname    = txtLastName.Text.Trim();
            objCustomer.Dinitialname = ddlInitialName.Text.Trim();
            objCustomer.Firstname    = txtFirstName.Text.Trim();
        }

        List <OrderLine> orderlines = new List <OrderLine>();

        foreach (GridViewRow row in grdOrderLine.Rows)
        {
            OrderLine orderline = new OrderLine();

            Label lblorderid = (Label)row.Cells[0].FindControl("lblOrderId");
            orderline.Orderid = Int32.Parse(lblorderid.Text);

            Label lblArticleCode = (Label)row.Cells[0].FindControl("lblArticleCode");
            orderline.Articlecode = lblArticleCode.Text;

            TextBox intCtrQuanity = (TextBox)row.Cells[2].FindControl("intCtrQuanity");
            orderline.Quantity = Convert.ToInt32(intCtrQuanity.Text);

            TextBox intCtrUnitPrice = (TextBox)row.Cells[4].FindControl("intCtrUnitPrice");
            orderline.Unitprice = Convert.ToDouble(intCtrUnitPrice.Text);

            TextBox intCtrDiscount = (TextBox)row.Cells[5].FindControl("intCtrDiscount");
            orderline.Discountpc = Convert.ToDouble(intCtrDiscount.Text);

            TextBox intCtrVat = (TextBox)row.Cells[6].FindControl("intCtrVat");
            orderline.Vatpc = Convert.ToDouble(intCtrVat.Text);

            orderlines.Add(orderline);
        }
        string msg = "";

        bool b = new Facade().UpdateOrder(objOrder, orderlines, objCustomer, num_order, ref msg);

        if (b == false)
        {
            lblError.Text = msg;
        }
        return(b);
    }
Example #57
0
 protected void AddToBasketButton_OnClick(object sender, EventArgs e)
 {
     string    sku        = HiddenSku.Value;
     string    variantSku = Request.Form["VariantSku"];
     OrderLine orderline  = TransactionLibrary.AddToBasket(1, sku, variantSku);
 }
Example #58
0
 private static void UpdateProperties(OrderLine orderLine)
 {
     orderLine.Quantity  = 6;
     orderLine.SellPrice = 5.99m;
     orderLine.Status    = OrderLineStatus.Allocated;
 }
Example #59
0
 public virtual void RemoveOrderLine(OrderLine orderLine)
 {
     if (_orderLines.Contains(orderLine))
     {
         _orderLines.Remove(orderLine);
         orderLine.Order = null;
     }
 }
Example #60
0
        public void ReadOrderById()
        {
            var id   = 1;
            var user = new PasswordUser
            {
                Id          = 1,
                FirstName   = "Bent",
                LastName    = "Nielsen",
                Email       = "*****@*****.**",
                PhoneNumber = "12345678",
                Country     = "Denmark",
                Street      = "H.C.Andersen gade 12",
                ZipCode     = "5000",
                Username    = "******",
                Password    = "******"
            };

            var cover = new Cover
            {
                Color       = "blue",
                Material    = "plastic",
                TypeOfBrand = "Apple",
                TypeOfModel = "iPhone6",
                Stock       = 10,
                Price       = 1234,
                Name        = "PanserProof"
            };

            var ol = new OrderLine
            {
                Product         = cover,
                ProductId       = cover.Id,
                Qty             = 2,
                PriceWhenBought = cover.Price
            };

            var order = new Order
            {
                Id           = id,
                User         = user,
                DeliveryDate = DateTime.Now,
                OrderDate    = DateTime.Now,
                OrderLines   = new List <OrderLine>
                {
                    ol,
                    new OrderLine
                    {
                        Product         = cover,
                        ProductId       = cover.Id,
                        Qty             = 2,
                        PriceWhenBought = cover.Price
                    }
                }
            };

            var orderRepo = new Mock <IOrderRepository>();

            orderRepo.Setup(x => x.GetOrderById(id)).Returns(order);
            var           userRepo = new Mock <IUserRepository>();
            IOrderService service  = new OrderService(orderRepo.Object, userRepo.Object);

            var result = service.GetOrderById(id);

            Assert.Equal(order, result);
        }