Beispiel #1
0
        public IActionResult Edit(int id, string returnUrl)
        {
            var userID    = Task.Run(async() => await userManager.FindByNameAsync(User.Identity.Name)).Result.Id;
            var rolecheck = (from role in context.UserRoles.ToList()
                             where role.UserId == userID
                             select role).FirstOrDefault();

            if (rolecheck != null)
            {
                ViewBag.ReturnUrl = returnUrl;
                var productOrderDetail = productOrderDetailRepository.Get(id);
                var od = new OrderViewModel();
                if (productOrderDetail != null)
                {
                    od.Name                 = productRepository.Get(productOrderDetail.ProductId).Name;
                    od.Price                = productRepository.Get(productOrderDetail.ProductId).Price;
                    od.PodId                = productOrderDetail.ProductOrderDetailId;
                    od.Count                = productOrderDetail.Count;
                    od.ProductId            = productOrderDetail.ProductId;
                    od.OrderDetailId        = productOrderDetail.OrderDetailId;
                    od.ProductOrderDetailId = id;
                    od.OrderId              = orderDetailRepository.Get(productOrderDetailRepository.Get(id).OrderDetailId).OrderId;
                    od.Total                = productRepository.Get(productOrderDetail.ProductId).Price *productOrderDetail.Count;
                    return(View(od));
                }
                else
                {
                    return(RedirectToAction("PageNotFound", "Error"));
                }
            }
            else
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }
        }
 public ProductOrderDetail Get(int entityID)
 {
     return(_productOrderDetailRepository.Get(x => x.ProductOrderDetailID == entityID));
 }