Exemplo n.º 1
0
 static void FindOrder()
 {
     try
     {
         BLUser bLUser = new BLUser()
         {
             Basket       = new MapperConfiguration(cfg => cfg.CreateMap <ProductView, BLProduct>()).CreateMapper().Map <IEnumerable <ProductView>, List <BLProduct> >(user.Basket),
             Orders       = new MapperConfiguration(cfg => cfg.CreateMap <OrderView, BLOrder>()).CreateMapper().Map <IEnumerable <OrderView>, List <BLOrder> >(user.Orders),
             Email        = user.Email,
             FirstName    = user.FirstName,
             Id           = user.Id,
             LastName     = user.LastName,
             Money        = user.Money,
             NumberofCard = user.NumberofCard,
             Pasword      = user.Pasword
         };
         Console.Write("Id of order: ");
         int     id      = Convert.ToInt32(Console.ReadLine());
         BLOrder blorder = orderService.GetOrder(bLUser, id);
         CurrentOrder = new OrderView()
         {
             Id = blorder.Id, Country = blorder.Country, NumberOfPost = blorder.NumberOfPost, ProductId = blorder.ProductId, Status = blorder.Status
         };
         Console.WriteLine(CurrentProduct);
     }
     catch (ValidateException ex)
     {
         Console.WriteLine(ex.Message);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 2
0
        public JsonResult fillstate(int id)
        {
            DLAddresses model = new DLAddresses();

            model.States = BLOrder.PopulateDropDown("StoredProcStates", id);
            return(Json(model.States));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsSecureConnection)
            {
                // Page only accessible by logged in user
                if (Session["LoginStatus"].Equals("User"))
                {
                    BLOrder order = Session["Order"] as BLOrder;

                    lblOrderID.Text = order.OrderID.ToString();
                    lblDate.Text    = string.Format("{0:d}", order.OrderDetails["ordDate"]);

                    lblSubtotal.Text = string.Format("{0:C}", order.OrderDetails["ordSubTotal"]);

                    lblShip.Text     = order.ShippingDetails["shipType"].ToString();
                    lblShipCost.Text = string.Format("{0:C}", order.ShippingDetails["shipCost"]);

                    lblTotal.Text = string.Format("{0:C}", order.OrderDetails["ordTotal"]);
                    lblGst.Text   = string.Format("{0:C}", order.OrderDetails["ordGST"]);

                    lsvItems.DataSource = order.OrderItems;
                    lsvItems.DataBind();
                }
                else
                {
                    Response.Redirect("~/UL/ErrorPage/0");
                }
            }
            else
            {
                // Make connection secure if it isn't already
                string url = ConfigurationManager.AppSettings["SecurePath"] + "ViewSingleOrder";
                Response.Redirect(url);
            }
        }
Exemplo n.º 4
0
        // GET: Order
        public ActionResult Orders()
        {
            if (Session["CustomerId"] != null)
            {
                int CustomerId = Convert.ToInt32(Session["CustomerId"]);
                ViewBag.OrderList = balOrder.DisplayOrder(CustomerId, "DisplayOrder");

                ViewBag.Countries = BLOrder.PopulateDropDown("StoredProcCountries", 0);

                ViewBag.States         = balOrder.CSCList("StoredProcStates");
                ViewBag.Cities         = balOrder.CSCList("StoredProcCities");
                ViewBag.TotalOrderList = balOrder.DisplayOrder(CustomerId, "OrderList");

                List <DLAddresses> list = balOrder.AddressExist(CustomerId);
                if (list.Count != 0)
                {
                    return(View(list[0]));
                }
            }
            else
            {
                TempData["Error"] = "Please SignIn first";
                return(Redirect("/Customer/Home"));
            }

            return(View());
        }
Exemplo n.º 5
0
        private void FrmInvoice_Load(object sender, EventArgs e)
        {
            try
            {
                dsDictionary.EnforceConstraints = false;
                BLOrder oBL   = new BLOrder();
                var     table = oBL.GetDataByID(SAInvoiceID);
                if (table.Rows.Count <= 0)
                {
                    BLSAInvoice oBLSAInvoice = new BLSAInvoice();
                    table = oBLSAInvoice.GetDataByID(SAInvoiceID);
                    // Nếu tạo mới từ Order
                    if (SAInvoiceID != Guid.Empty)
                    {
                        btnSave.Visible = true;
                        dsDictionary.Clear();
                        dsDictionary.SAInvoice.Merge(oBLSAInvoice.GetDataByID(SAInvoiceID), false, MissingSchemaAction.Ignore);
                        dsDictionary.SAInvoiceDetail.Merge(oBLSAInvoice.GetDataDetailByID(SAInvoiceID), false, MissingSchemaAction.Ignore);
                        CreateSAInvoice();
                    }
                    // Nếu không phải tạo mới thì load dữ liệu
                    else
                    {
                        btnSave.Visible = false;
                        LoadSAInvoice();
                    }
                }
                else
                {
                    // Nếu tạo mới từ Order
                    if (SAInvoiceID != Guid.Empty)
                    {
                        btnSave.Visible = true;
                        dsDictionary.Clear();
                        dsDictionary.Order.Merge(oBLOrder.GetDataByID(SAInvoiceID), false, MissingSchemaAction.Ignore);
                        dsDictionary.OrderDetail.Merge(oBLOrder.GetDataDetailByID(SAInvoiceID), false, MissingSchemaAction.Ignore);
                        CreateSAInvoice();
                    }
                    // Nếu không phải tạo mới thì load dữ liệu
                    else
                    {
                        btnSave.Visible = false;
                        LoadSAInvoice();
                    }
                }

                if (table != null && table.Rows.Count > 0)
                {
                    SAInvoiceRow = dsDictionary.SAInvoice.FirstOrDefault();
                    dsDictionary.Customer.Merge(new BLCustomer().GetDataByID(Guid.Parse(table.Rows[0][5].ToString())));
                    CustomerRow = dsDictionary.Customer.FindByCustomerID(Guid.Parse(table.Rows[0][5].ToString()));
                }

                BindingData(table);
            }
            catch (Exception ex)
            {
                MessageBoxCommon.ShowException(ex);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create an order
        /// </summary>
        /// <param name="user">User whose order will be got</param>
        /// <param name="order">Orderf that will be added to the order list</param>
        /// <exception cref="ValidateException">Thrown if parameter was null</exception>
        public void MakeOrder(BLUser user, BLOrder order)
        {
            Product product = DB.Products.Get(order.ProductId);

            if (product is null)
            {
                throw new ValidateException("The product cannot be null");
            }
            else if (user is null)
            {
                throw new ValidateException("The user cannot be null");
            }
            else
            {
                Order newOrder = new Order()
                {
                    NumberOfPost = order.NumberOfPost,
                    Country      = order.Country,
                    ProductId    = product.Id,
                    Id           = user.Orders.Count + 1,
                    Status       = order.Status
                };
                User u = DB.Users.Get(user.Id);
                u.Orders.Add(newOrder);
            }
        }
Exemplo n.º 7
0
        // COPIED FROM AdminItemManagment.aspx.cs
        // Redirect to appropriate update page
        protected void gvOrders_SelectedIndexChanged(object sender, EventArgs e)
        {
            int orderID = Convert.ToInt32(gvOrders.SelectedRow.Cells[0].Text);

            BLOrder order = new BLOrder();

            Session["Order"] = order.getOrder(orderID);

            Response.Redirect("~/UL/ViewSingleOrder");
        }
Exemplo n.º 8
0
 protected void SubmitOrder_Click(object sender, EventArgs e)
 {
     if (Page.IsValid && cartList != null)
     {
         double  shippingCost;
         string  shippingMethod = ShippingDrowdown(out shippingCost);
         BLOrder order          = new BLOrder(postage: shippingCost, totalPrice: totalCartPrice, address: customer_address.Text, postalCode: customer_postalcode.Text, city: customer_city.Text, country: customer_country.Text, email: customer_email.Text, telephone: customer_phone.Text, paymentOptions: PaymentDropdown(), deliveryOptions: shippingMethod, name: customer_name.Text, surname: customer_surname.Text, cartProducts: cartList);
         order.InsertIntoDB(connectionString);
         Session["orderId"]   = order.Id;
         Session["cartList"]  = null;
         Session["cartCount"] = null;
         Response.Redirect("/ReceiptPage.aspx");
     }
 }
Exemplo n.º 9
0
        public JsonResult AjaxMethod(string type, int value)
        {
            DLAddresses model = new DLAddresses();

            switch (type)
            {
            case "CountryId":
                model.States = BLOrder.PopulateDropDown("StoredProcStates", value);
                break;

            case "StateId":
                model.Cities = BLOrder.PopulateDropDown("StoredProcCities", value);
                break;
            }
            return(Json(model));
        }
Exemplo n.º 10
0
        public void CreateOrder_TestForAdmin()
        {
            BLAdmin admin = new BLAdmin()
            {
                Id = 12, Email = "qwerty@", FirstName = "Name", LastName = "LastName", NumberofCard = 1234567890, Pasword = "qwerty1234"
            };
            BLOrder order = new BLOrder()
            {
                Id = 2, Country = "Ukraine", NumberOfPost = 12, ProductId = 3, Status = DAL.Enums.Statuses.New
            };

            userService.AddUser(admin);
            orderService.MakeOrder(admin, order);

            Assert.AreEqual(order.ProductId, orderService.GetOrders(admin).Last().ProductId);
        }
Exemplo n.º 11
0
        public void ChangeStatus_Test(Statuses status)
        {
            BLAdmin admin = new BLAdmin()
            {
                Id = 12, Email = "qwerty@", FirstName = "Name", LastName = "LastName", NumberofCard = 1234567890, Pasword = "qwerty1234"
            };
            BLOrder order = new BLOrder()
            {
                Id = 2, Country = "Ukraine", NumberOfPost = 12, ProductId = 3, Status = DAL.Enums.Statuses.New
            };

            userService.AddUser(admin);
            orderService.MakeOrder(admin, order);
            orderService.ChangeStatus(admin, orderService.GetOrders(admin).Last().Id, status);

            Assert.That(orderService.GetOrders(admin).Last().Status == status);
        }
Exemplo n.º 12
0
        static void CreateOrder()
        {
            try
            {
                BLUser bLUser = new BLUser()
                {
                    Basket       = new MapperConfiguration(cfg => cfg.CreateMap <ProductView, BLProduct>()).CreateMapper().Map <IEnumerable <ProductView>, List <BLProduct> >(user.Basket),
                    Orders       = new MapperConfiguration(cfg => cfg.CreateMap <OrderView, BLOrder>()).CreateMapper().Map <IEnumerable <OrderView>, List <BLOrder> >(user.Orders),
                    Email        = user.Email,
                    FirstName    = user.FirstName,
                    Id           = user.Id,
                    LastName     = user.LastName,
                    Money        = user.Money,
                    NumberofCard = user.NumberofCard,
                    Pasword      = user.Pasword
                };

                Console.Write("ProductId: ");
                int productId = Convert.ToInt32(Console.ReadLine());
                while (productId < 0 || productId > productService.GetBasket(bLUser).Count())
                {
                    Console.WriteLine("\nWrite a number one more time");
                    productId = Convert.ToInt32(Console.ReadLine());
                }
                Console.Write("\nCountry: ");
                string country = Console.ReadLine();
                Console.Write("\nNumber of post: ");
                int number = Convert.ToInt32(Console.ReadLine());

                BLOrder order = new BLOrder()
                {
                    Country = country, NumberOfPost = number, ProductId = productId, Status = Statuses.New
                };

                orderService.MakeOrder(bLUser, order);
            }
            catch (ValidateException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Edits the information of order
        /// Changes country
        /// </summary>
        /// <param name="user"></param>
        /// <param name="order"></param>
        /// <param name="number"></param>
        /// <exception cref="ValidateException">Thrown if parameter was null</exception>
        public void EditOrder(BLUser user, BLOrder order, int number)
        {
            if (order is null)
            {
                throw new ValidateException("The order cannot be null");
            }
            else if (user is null)
            {
                throw new ValidateException("The user cannot be null");
            }
            Order orderMain = DB.Users.Get(user.Id).Orders.Find(f => f.Id == order.Id);

            if (orderMain is null)
            {
                throw new ValidateException("The odrer cannot be null");
            }
            orderMain.NumberOfPost = number;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Edits the information of order
        /// Changes country
        /// </summary>
        /// <param name="user">User whose order will be got</param>
        /// <param name="order"></param>
        /// <param name="country"></param>
        /// <exception cref="ValidateException">Thrown if parameter was null</exception>
        public void EditOrder(BLUser user, BLOrder order, string country)
        {
            if (order is null)
            {
                throw new ValidateException("The order cannot be null");
            }
            else if (user is null)
            {
                throw new ValidateException("The user cannot be null");
            }
            Order orderMain = DB.Users.Get(user.Id).Orders.Find(f => f.Id == order.Id);

            if (orderMain is null)
            {
                throw new ValidateException("The order cannot be null");
            }
            orderMain.Country = country;
        }
Exemplo n.º 15
0
        public object GetOrderByID(Guid itemID)
        {
            ServiceResult result = new ServiceResult();
            List <Order>  items;

            try
            {
                items          = new BLOrder().GetOrder(itemID);
                result.Success = true;
                result.Data    = items;
            }
            catch (Exception ex)
            {
                CommonFunction.WriteLog(ex, SerializeUtil.Serialize(itemID), Request.RequestUri.ToString());
                result.Success   = false;
                result.ErrorCode = ex.Message;
            }
            return(result);
        }
Exemplo n.º 16
0
        public object GetOrdersByOrderStatus(int orderStatus)
        {
            ServiceResult        result = new ServiceResult();
            List <OrderResponse> items;

            try
            {
                items          = new BLOrder().GetOrdersTodayWithOrderStatus(orderStatus);
                result.Success = true;
                result.Data    = items;
            }
            catch (Exception ex)
            {
                CommonFunction.WriteLog(ex, SerializeUtil.Serialize(orderStatus + ""), Request.RequestUri.ToString());
                result.Success   = false;
                result.ErrorCode = ex.Message;
            }
            return(result);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Edits the information of order
        /// Changes country
        /// </summary>
        /// <param name="user"></param>
        /// <param name="order"></param>
        /// <param name="newOrder"></param>
        /// <exception cref="ValidateException">Thrown if parameter was null</exception>
        public void EditOrder(BLUser user, BLOrder order, BLOrder newOrder)
        {
            if (order is null)
            {
                throw new ValidateException("The order cannot be null");
            }
            else if (user is null)
            {
                throw new ValidateException("The user cannot be null");
            }
            Order orderMain = DB.Users.Get(user.Id).Orders.Find(f => f.Id == order.Id);

            if (orderMain is null)
            {
                throw new ValidateException("The order cannot be null");
            }
            orderMain = new Order()
            {
                Id = orderMain.Id, Country = newOrder.Country, NumberOfPost = newOrder.NumberOfPost, ProductId = newOrder.ProductId, Status = newOrder.Status
            };
        }
Exemplo n.º 18
0
        //Invoice Menu
        public PartialViewResult LoadReceiptDetail(int id)
        {
            var blInvoice = new BLInvoice();

            var invoice = blInvoice.GetInvoiceFullInfoById(id);

            if (invoice == null)
            {
                return(PartialView("_EmptyReviewOrder", new VMHandleErrorInfo
                {
                    ErrorMessage = "In order to see the detail of your receipt, " +
                                   "please complete all team member(s) registration forms."
                }));
            }

            var blOrder           = new BLOrder();
            var completeOrderInfo = blOrder.GetCompleteOrder(CurrentUserId, id);

            invoice.Received      = completeOrderInfo.Received.Value.ToShortDateString();
            invoice.TransactionNo = completeOrderInfo.TransactionNo;

            return(PartialView("LastReceiptForm", invoice));
        }
Exemplo n.º 19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.IsSecureConnection)
     {
         // Page only accessible to a logged in user
         if (Session["LoginStatus"].ToString().Equals("User"))
         {
             BLUser user = Session["CurrentUser"] as BLUser;
             gvOrders.DataSource = BLOrder.getUserOrders(user);
             gvOrders.DataBind();
         }
         else
         {
             // Unauthorised
             Response.Redirect("~/UL/ErrorPage/0");
         }
     }
     else
     {
         // Make connection secure if it isn't already
         string url = ConfigurationManager.AppSettings["SecurePath"] + "PurchaseHistory";
         Response.Redirect(url);
     }
 }
Exemplo n.º 20
0
 public OrderController()
 {
     _repo = new BLOrder();
 }
Exemplo n.º 21
0
 protected void Page_Load(object sender, EventArgs e)
 {
     order = BLOrder.RetrieveFromDB(connectionString, (int)Session["orderId"]);
     ShowOrderInfo();
     ShowOrderProducts();
 }
Exemplo n.º 22
0
 public OrderController()
 {
     _repo      = new BLOrder();
     _trackRepo = new BLTracking();
 }