Example #1
0
        /// <summary>
        /// In here we run our bll to find our top seller.
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            ActionResult response;

            try
            {
                if (ModelState.IsValid)
                {                //Create a list of of buissness logic to send to the bo.
                    List <OrderBO> users = new List <OrderBO>();
                    //Call from do to the dao to view the prices
                    List <OrderDO> PricesMapped = ordersDAO.ViewPrices();
                    //Map Do back to the BO  and add to the list until all are added
                    foreach (OrderDO displayObject in PricesMapped)
                    {
                        users.Add(mapper.MapDoToBo(displayObject));
                    }
                    //take the top user in the data base based on their sales
                    //we will also take the id that is passed back and put into view by username
                    long userID = pcBO.ViewNumberOne(users);

                    //Map DO with user to A po
                    OrderDO username = ordersDAO.ViewUsernameByID(userID);
                    Order   topUser  = mapper.MapDoToPO(username);


                    response = View(topUser);
                }
                else
                {
                    response = View();
                }
            }
            catch
            {
                response = View();
            }
            return(response);
        }
Example #2
0
        public ActionResult ConfirmOrder(long pcID)
        {
            ActionResult response;

            if (!((string)Session["RoleName"] == null))
            {
                Order order = new Order();
                order.PcID = pcID;
                if (pcID > 0)
                {
                    long   userId   = (long)Session["UserId"];
                    string Username = (string)Session["Username"];
                    //Map User
                    UserDO userDO = userDao.ViewUserByID(userId);
                    User   user   = userMapper.MapDOtoPO(userDO);

                    PcDO pc       = pcDAO.ViewDetails(pcID);
                    PC   mappedPc = pcMapper.MapDoToPO(pc);


                    try
                    {
                        if (ModelState.IsValid)
                        {
                            OrderDO OrderObject = new OrderDO()
                            {
                                pcID    = mappedPc.PcID,
                                pcName  = mappedPc.PcName,
                                Address = user.Address,
                                Country = user.Country,
                                OrderID = order.OrderID,

                                price    = mappedPc.Price,
                                userID   = user.UserID,
                                userName = user.Username
                            };

                            OrderDO orderDo = ordersDAO.ViewOrderByPCID(pcID);
                            Order   orderPo = orderMapper.MapDoToPO(orderDo);
                            response = View(orderPo);
                        }
                        else
                        {
                            response = RedirectToAction("Store", "Pc");
                        }
                    }
                    catch
                    {
                        response = RedirectToAction("Login", "Account");
                    }
                    return(response);
                }
                else
                {
                    response = RedirectToAction("Store", "Store");
                }
                return(View());
            }
            else
            {
                response = RedirectToAction("Login", "Account");
            }
            return(response);
        }