Ejemplo n.º 1
0
        public ActionResult CreateNewOrder(OrdersPO form)
        {
            ActionResult response;

            //checking modelstate
            if (ModelState.IsValid)
            {
                try
                {
                    //taking user input and saving it to the database
                    OrdersDO newOrder = Mapper.OrdersPOtoOrdersDO(form);
                    _OrdersDAO.CreateNewOrder(newOrder);
                    //redirecting to Order page when finished
                    response = RedirectToAction("ViewOrderByUserID", "Orders", new { newOrder.UserID });
                }
                //logging errors and redirecting
                catch (SqlException sqlEx)
                {
                    Logger.SqlErrorLog(sqlEx);
                    response = View("Error");
                }
                catch (Exception ex)
                {
                    Logger.ErrorLog(ex);
                    response = View("Error");
                }
            }
            else
            {
                //returning to form view if model state is invalid
                response = View(form);
            }
            //returning to home page
            return(response);
        }
        public ActionResult Create(OrderPO form)
        {
            ActionResult oResponse = RedirectToAction("Index", "Game");

            if (ModelState.IsValid)
            {
                try
                {
                    form.UserID = (Int64)Session["UserID"];
                    OrdersDO dataObject = OrderMapper.MapPoToDo(form);
                    dataAccess.CreateNewOrder(dataObject, Session["Cart"] as List <int>);

                    TempData["Message"] = $"{form.Name} order has been created";
                }
                catch (Exception ex)
                {
                    oResponse = View(form);
                }
            }
            else
            {
                oResponse = View(form);
            }
            Session["Cart"] = null;
            return(oResponse);
        }