コード例 #1
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);
        }