コード例 #1
0
        private async Task <bool> FetchData(int producttypeId)
        {
            Employee = await userManager.GetUserAsync(User).ConfigureAwait(false);

            Role = await roleManager.FindByIdAsync(Employee.RoleId.ToString()).ConfigureAwait(false);

            if (!Role.CanAdministerSystem)
            {
                return(false);
            }

            var producttype = (await producttypes.FetchProductType(producttypeId).ConfigureAwait(false))
                              .Ensure(e => e.HasValue, "Product Type found")
                              .OnSuccess(e => e.Value);

            if (producttype.IsFailure)
            {
                return(false);
            }

            Title = producttype.Value.ProductTypeName;

            Input ??= new InputModel
            {
                ProductTypeName = producttype.Value.ProductTypeName,
            };

            return(true);
        }
コード例 #2
0
ファイル: ProductType.cs プロジェクト: Mesh-Tech/koasta
        private async Task <bool> FetchData(int producttypeId)
        {
            Employee = await userManager.GetUserAsync(User).ConfigureAwait(false);

            Role = await roleManager.FindByIdAsync(Employee.RoleId.ToString()).ConfigureAwait(false);

            if (!Role.CanAdministerSystem)
            {
                return(false);
            }

            var result = (await producttypes.FetchProductType(producttypeId).ConfigureAwait(false))
                         .Ensure(e => e.HasValue, "Product Type found")
                         .OnSuccess(e => e.Value);

            ProductType = result.IsSuccess ? result.Value : null;
            Title       = ProductType.ProductTypeName;
            return(result.IsSuccess);
        }
コード例 #3
0
        private async Task <bool> FetchData(int productId)
        {
            Employee = await userManager.GetUserAsync(User).ConfigureAwait(false);

            Role = await roleManager.FindByIdAsync(Employee.RoleId.ToString()).ConfigureAwait(false);

            if (!Role.CanWorkWithVenue)
            {
                return(false);
            }

            var result = (await products.FetchProduct(productId).ConfigureAwait(false))
                         .Ensure(e => e.HasValue, "Product found")
                         .OnSuccess(e => e.Value);

            Product = result.IsSuccess ? result.Value : null;

            var productVenue = (await venues.FetchVenue(Product.VenueId).ConfigureAwait(false))
                               .Ensure(e => e.HasValue, "Venue found")
                               .OnSuccess(e => e.Value);

            var result2 = (await productTypes.FetchProductType(Product.ProductType).ConfigureAwait(false))
                          .Ensure(e => e.HasValue, "Product type found")
                          .OnSuccess(e => e.Value);

            ProductType = result2.IsSuccess ? result2.Value.ProductTypeName : null;

            if (productVenue.IsFailure)
            {
                return(false);
            }

            if (!Role.CanAdministerSystem && productVenue.Value.CompanyId != Employee.CompanyId)
            {
                return(false);
            }

            ViewData["SubnavVenueId"] = Product.VenueId;
            Title = Product.ProductName;
            return(result.IsSuccess);
        }