コード例 #1
0
        public async Task <ActionResult <WorkingFormViewModel> > GetCurrentWorkingFormOfDesignShop(Guid designShopId)
        {
            // Check if designshop exists
            if (!DesignShopExists(designShopId))
            {
                _logger.LogError($"Unknown designshop, asked for id {designShopId}");
                return(NotFound());
            }

            _logger.LogTrace($"Searching current workingform for designshop id {designShopId}.");

            DesignShop shop = await _context.DesignShop
                              .Where(shop => shop.Id == designShopId)
                              .Include(shop => shop.CurrentDesignShopWorkingForm)
                              .ThenInclude(wf => wf.WorkingForm)
                              .FirstOrDefaultAsync();

            var currentWorkingForm = new WorkingFormViewModel();

            if (shop == null)
            {
                _logger.LogTrace($"Designshop with id {designShopId} doesn't have a current workingform.'");
            }
            else
            {
                currentWorkingForm = new WorkingFormViewModel()
                {
                    Id = shop.CurrentDesignShopWorkingForm.Id, Description = shop.CurrentDesignShopWorkingForm.WorkingForm.Description
                };
                _logger.LogTrace(
                    $"Designshop with id {designShopId} has workingform with id {currentWorkingForm.Id} as active workingform.");
            }

            return(currentWorkingForm);
        }
コード例 #2
0
        private void MockDesignShops()
        {
            // Setup several empty designshops
            for (var i = 0; i < 6; i++)
            {
                _applicationTestDbContext.DesignShop.Add(new DesignShop()
                {
                    Date = DateTime.Now
                });
            }

            // Add one we'll remember
            _designShop = new DesignShop()
            {
                Date = DateTime.Now, Description = "Remember this!"
            };
            _applicationTestDbContext.DesignShop.Add(_designShop);

            // And throw in another empty designshops
            for (var i = 0; i < 6; i++)
            {
                _applicationTestDbContext.DesignShop.Add(new DesignShop()
                {
                    Date = DateTime.Now
                });
            }

            _applicationTestDbContext.SaveChanges();
        }
コード例 #3
0
        public async Task <ActionResult <DesignShop> > CreateDesignShop()
        {
            // Currently, we only need an empty DesignShop so we'll create it here.
            _logger.LogTrace("Creating new Design Shop.");
            DesignShop designShop = new DesignShop();

            _context.DesignShop.Add(designShop);
            await _context.SaveChangesAsync();

            _logger.LogTrace($"New Design Shop created with id {designShop.Id}");

            return(CreatedAtAction("GetDesignShop", new { id = designShop.Id }, designShop));
        }
コード例 #4
0
        private void MockDesignShops()
        {
            // Setup several empty designshops
            for (var i = 0; i < 6; i++)
            {
                _applicationTestDbContext.DesignShop.Add(new DesignShop());
            }

            // Add one we'll remember
            _designShopWithCurrentWorkingForm = new DesignShop();
            _applicationTestDbContext.DesignShop.Add(_designShopWithCurrentWorkingForm);

            // Add another one, but we'll not going to add workingforms to this one
            _designShopWithoutCurrentWorkingForm = new DesignShop();
            _applicationTestDbContext.DesignShop.Add(_designShopWithoutCurrentWorkingForm);

            // And throw in another empty designshops
            for (var i = 0; i < 6; i++)
            {
                _applicationTestDbContext.DesignShop.Add(new DesignShop());
            }

            _applicationTestDbContext.SaveChanges();
        }