コード例 #1
0
        public async Task <ActionResult> Details(int pq, int customerID, int?id)
        {
            ViewBag.Pq         = pq;
            ViewBag.CustomerID = customerID;

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            CustomerOrder customerOrder = await customerOrderRepository.FindCustomerOrdersByIDAsync((int)id);

            if (customerOrder == null)
            {
                return(HttpNotFound());
            }

            Boolean canShowCosteo = await customerProductRepository.CanShowCosteoAsync(customerOrder.ProductQuote.CustomerID, customerOrder.ProductQuote.ProductID);

            //Si no se puede ver el Costeo por Customer/Product, nos fijamos si el usuario logueado es CustomerAdminUser
            if (!canShowCosteo && User.IsInRole("CustomerAdminUser"))
            {
                canShowCosteo = true;
            }

            customerOrder.ProductQuote.CanShowCosteo = canShowCosteo;
            return(View(new CustomerOrderViewModel(customerOrder)));
        }
コード例 #2
0
        public async Task <ActionResult> Details(int pq, int customerID, int id)
        {
            ProductQuote productQuote;

            if (userManager.IsInRole(HttpContext.User.Identity.GetUserId(), "SuperAdminUser"))
            {
                productQuote = await productQuoteRepository.FindProductQuotesByIDAsync(id);
            }
            else
            {
                if ((userManager.IsInRole(HttpContext.User.Identity.GetUserId(), "AdminUser")) || (userManager.IsInRole(HttpContext.User.Identity.GetUserId(), "SellerUser")))
                {
                    productQuote = await productQuoteRepository.FindProductQuotesByIDUserIDAsync(id, base.CurrentUserId);
                }
                else
                {
                    productQuote = await productQuoteRepository.FindProductQuotesByIDCustomerAndUserIDAsync(id, base.CurrentCustomerID, base.CurrentUserId);
                }
            }

            ViewBag.Pq         = pq;
            ViewBag.CustomerID = customerID;

            if (productQuote == null)
            {
                return(HttpNotFound());
            }

            Boolean canShowCosteo = await customerProductRepository.CanShowCosteoAsync(productQuote.CustomerID, productQuote.ProductID);

            //Si no se puede ver el Costeo por Customer/Product, nos fijamos si el usuario logueado es CustomerAdminUser
            if (!canShowCosteo && User.IsInRole("CustomerAdminUser"))
            {
                canShowCosteo = true;
            }

            productQuote.CanShowCosteo = canShowCosteo;
            return(View(new ProductQuoteViewModel(productQuote)));
        }