Ejemplo n.º 1
0
        public Result<Order> AddOrder(Order order)
        {
            Result<Order> result = new Result<Order>();

            try
            {
                result.Data = manager.Create(order);
                result.Status = ResultEnum.Success;
            }
            catch
            {
                result.Status = ResultEnum.Fail;
            }

            return result;
        }
Ejemplo n.º 2
0
        public ActionResult Feedback(FeedbackViewModel model)
        {
            Order order = new Order();
            string errorMessage = "Sorry, we are currently unable to save feedback for this order.";

            if (ModelState.IsValid)
            {
                // Get the Order
                try
                {
                    Result<Order> result = orderService.GetOrderById(model.OrderId);
                    if (result.Status == ResultEnum.Success)
                    {
                        order = result.Data;
                    }
                    else
                    {
                        ModelState.AddModelError("ErrorMessage", errorMessage);
                        return View(model);
                    }
                }
                catch
                {
                    ModelState.AddModelError("ErrorMessage", errorMessage);
                    return View(model);
                }

                // Update Order
                try
                {
                    order.Feedback = model.Feedback;
                    ResultEnum result = orderService.UpdateOrder(order);

                    if (result != ResultEnum.Success)
                    {
                        ModelState.AddModelError("ErrorMessage", errorMessage);
                        return View(model);
                    }

                    ViewData["SuccessMessage"] = "Thankyou for your feedback.";
                    return View(model);
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("ErrorMessage", errorMessage);
                    return View(model);
                }
            }

            ModelState.AddModelError("ErrorMessage", errorMessage);
            return View(model);
        }
Ejemplo n.º 3
0
        public ResultEnum UpdateOrder(Order order)
        {
            try
            {
                // Get new voucher code
                if (order.Paid && order.VoucherCode == 0)
                {
                    order.VoucherCode = manager.Get(p => true).Select(p => p.VoucherCode).Max() + 1;
                }

                manager.Update(order);
                return ResultEnum.Success;
            }
            catch
            {
                return ResultEnum.Fail;
            }
        }