Ejemplo n.º 1
0
        public ActionResult ConfirmAssign(int OrderID)
        {
            OrdersDO Order        = _OrdersDAO.ViewOrderByID(OrderID);
            OrdersPO orderDetails = Mapper.OrdersDOtoOrdersPO(Order);

            return(View(orderDetails));
        }
Ejemplo n.º 2
0
        public ActionResult UpdateOrder(OrdersPO form)
        {
            ActionResult response;

            //checking modelstate
            if (ModelState.IsValid)
            {
                try
                {
                    //mapping user inpit to database
                    OrdersDO OrderDO = Mapper.OrdersPOtoOrdersDO(form);
                    _OrdersDAO.UpdateOrder(OrderDO);
                    response = RedirectToAction("ViewOrderByID", "Orders", new { OrderDO.OrderID });
                }
                //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);
            }
            //return view
            return(response);
        }
Ejemplo n.º 3
0
        public ActionResult UpdateOrder(int OrderID)
        {
            ActionResult response;

            try
            {
                //mapping user input to database
                OrdersDO orderDO = _OrdersDAO.ViewOrderByID(OrderID);
                OrdersPO orderPO = Mapper.OrdersDOtoOrdersPO(orderDO);

                response = View(orderPO);
            }
            //logging errors and redirecting
            catch (SqlException sqlEx)
            {
                Logger.SqlErrorLog(sqlEx);
                response = View("Error");
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ex);
                response = View("Error");
            }
            //return view
            return(response);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public ActionResult CreateNewOrder()
        {
            ActionResult response;

            try
            {
                OrdersPO newOrder = new OrdersPO();
                newOrder.Requested = DateTime.Now;
                newOrder.Status    = 1;
                newOrder.UserID    = (int)Session["UserID"];
                newOrder.Due       = DateTime.Now.AddDays(7);
                response           = View(newOrder);
            }
            //logging errors and redirecting
            catch (SqlException sqlEx)
            {
                Logger.SqlErrorLog(sqlEx);
                response = View("Error");
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ex);
                response = View("Error");
            }
            //return view
            return(response);
        }
Ejemplo n.º 6
0
        //Mapping to presentation layer from DLL
        public static OrdersPO OrdersDOtoOrdersPO(OrdersDO from)
        {
            //mapping each individual attribute
            OrdersPO to = new OrdersPO();

            to.OrderID    = from.OrderID;
            to.UserID     = from.UserID;
            to.Requested  = from.Requested;
            to.Due        = from.Due;
            to.CrafterID  = from.CrafterID;
            to.Status     = from.Status;
            to.Username   = from.Username;
            to.Crafter    = from.Crafter;
            to.Pricetotal = from.Pricetotal;
            //making it usable in future
            return(to);
        }
Ejemplo n.º 7
0
        public ActionResult ViewOrderByID(int OrderID)
        {
            ActionResult response;
            OrdersVM     orderDetails = new OrdersVM();

            try
            {
                //mapping all the data to the view page
                OrdersPO       order      = Mapper.OrdersDOtoOrdersPO(_OrdersDAO.ViewOrderByID(OrderID));
                List <ItemsPO> orderItems = Mapper.ItemsListDOtoPO(_ItemsDAO.ItemsByOrderID(OrderID));

                //sending to business logic layer
                OrdersBO       calcOrder = Mapper.OrdersPOtoOrdersBO(order);
                List <ItemsBO> calcItems = Mapper.ItemsListPOtoBO(orderItems);

                //doing valculations
                calcOrder        = Calculation.PriceTotalCalculator(calcItems);
                order.Pricetotal = calcOrder.Pricetotal;

                //assigning new total price
                OrdersDO newTotal = Mapper.OrdersPOtoOrdersDO(order);
                _OrdersDAO.UpdateOrderPricetotal(newTotal);

                //assigning objects to viewmodel
                orderDetails.Order = order;
                orderDetails.Items = orderItems;

                response = View(orderDetails);
            }
            //logging errors and redirecting
            catch (SqlException sqlEx)
            {
                Logger.SqlErrorLog(sqlEx);
                response = View("Error");
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ex);
                response = View("Error");
            }
            //return view
            return(response);
        }
Ejemplo n.º 8
0
        public ActionResult AssignMeToOrder(OrdersPO form)
        {
            ActionResult response;

            if (ModelState.IsValid)
            {
                try
                {
                    OrdersDO newInfo = Mapper.OrdersPOtoOrdersDO(form);
                    //running the stored procedure

                    newInfo.CrafterID = (int)Session["UserID"];
                    newInfo.Crafter   = (string)Session["Username"];
                    newInfo.Status    = 2;
                    _OrdersDAO.UpdateOrderCrafter(newInfo);

                    response = RedirectToAction("ViewOrderByID", "Orders", new { form.OrderID });
                }
                //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 response page
            return(response);
        }