Exemple #1
0
        public async Task <ActionResult> Update(vm.Order order)
        {
            try
            {
                if (order.OrderNumber == Guid.Empty)
                {
                    return(BadRequest());
                }

                //Make sure the logged in user is the same user as the user in the order
                if (!CanAccessRecords(order.UserId))
                {
                    return(StatusCode(403));
                }

                if (await _orderService.UpdateOrder(_mapper.Map <dm.Orders.Order>(order)))
                {
                    return(RedirectToAction(nameof(OrderConfirmation), new { id = order.OrderNumber.GetSubString(), updated = true }));
                }

                return(NotFound());
            }
            catch
            {
                ViewBag.ErrorMessage = "Something went wrong processing your order :(";
                return(RedirectToAction(nameof(Index)));
            }
        }
Exemple #2
0
        public async Task <ActionResult> Create(vm.Order order)
        {
            try
            {
                order.UserId = CurrentUser;
                var response = await _orderService.GenerateNewOrder(_mapper.Map <dm.Orders.Order>(order));

                return(RedirectToAction(nameof(OrderConfirmation), new { id = response.OrderNumber.GetSubString(), updated = false }));
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = "Something went wrong processing your order :(";
                return(RedirectToAction(nameof(Index)));
            }
        }