예제 #1
0
        public PartialViewResult ProductSummary(Product product)
        {
            var pictures = context.Pictures.Where(x => x.Product.Id == product.Id);
            ProductSummaryViewModel model = new ProductSummaryViewModel {
                Product = product, Pictures = pictures
            };

            return(PartialView("ProductSummary", model));
        }
예제 #2
0
        public async void ProductSummary()
        {
            // Arrange
            this.QuarryDbContext.MaterialColours.AddRange(
                new MaterialColourEntity()
            {
                MaterialColourId = 1, ColourName = "White", CompanyId = 1, DeletedInd = false
            },
                new MaterialColourEntity()
            {
                MaterialColourId = 2, ColourName = "Smoky", CompanyId = 1, DeletedInd = false
            });

            this.QuarryDbContext.ProductTypes.AddRange(
                new ProductTypeEntity()
            {
                ProductTypeId = 1, ProductTypeName = "Slab", CompanyId = 1, DeletedInd = false
            },
                new ProductTypeEntity()
            {
                ProductTypeId = 2, ProductTypeName = "Tile", CompanyId = 1, DeletedInd = false
            });

            this.QuarryDbContext.Quarries.AddRange(
                new QuarryEntity()
            {
                QuarryId = 1, QuarryName = "QM1", CompanyId = 1, DeletedInd = false
            },
                new QuarryEntity()
            {
                QuarryId = 2, QuarryName = "QM2", CompanyId = 1, DeletedInd = false
            });

            await this.SaveChangesAsync(this.QuarryDbContext);

            await this.ProductSummaryArrange();

            // Act
            AjaxModel <ProductSummaryViewModel> ajaxModel = await this.Controller.ProductSummary();

            ProductSummaryViewModel viewModel = ajaxModel.Model;

            // Assert
            Assert.Equal(viewModel.Colours[1].Item, "White");
            Assert.Equal(viewModel.ProductTypes[1].Item, "Tile");
            Assert.Equal(viewModel.Quarries[1].Item, "QM2");
            this.ProductSummaryAssert(viewModel.Summary);
        }
예제 #3
0
        public static List <ProductSummaryViewModel> ConvertToProductSummary(IEnumerable <ProductBacklog> products)
        {
            var summaryList = new List <ProductSummaryViewModel>();

            foreach (var product in products)
            {
                var newSummary = new ProductSummaryViewModel
                {
                    ProductId           = product.Id,
                    ProductName         = product.Name,
                    BacklogUserStories  = product.UserStories.Count(i => i.ReleaseId == null),
                    ScrumMasters        = product.ReleaseBacklogs.Select(i => i.ScrumMasterId).Distinct().Count(),
                    Releases            = product.ReleaseBacklogs.Count(),
                    AssignedUserStories = product.UserStories.Count(i => i.DevelopedId != null || i.TesterId != null),
                    Developers          = product.UserStories.Where(i => i.DevelopedId != null).Select(i => i.DevelopedId).Distinct().Count(),
                    Sprints             = product.ReleaseBacklogs.Select(i => i.Sprints).Count(),
                    Testers             = product.UserStories.Where(i => i.TesterId != null).Select(i => i.TesterId).Distinct().Count(),
                    PercentCompleted    = product.UserStories.Any() ? product.UserStories.Select(i => i.PercentageCompleted()).Sum() / product.UserStories.Count() : 0
                };
                summaryList.Add(newSummary);
            }
            return(summaryList);
        }