コード例 #1
0
        private void MockWorkingForms()
        {
            WorkingForm           workingForm;
            DesignShopWorkingForm designShopWorkingForm;

            // We'll add 5 workingforms to the saved designshop
            // The fourth workingform will act as the current workingform
            for (var i = 1; i < 6; i++)
            {
                workingForm = new WorkingForm()
                {
                    Description = $"Workingform {i}"
                };
                _applicationTestDbContext.WorkingForm.Add(workingForm);
                designShopWorkingForm = new DesignShopWorkingForm()
                {
                    DesignShop = _designShopWithCurrentWorkingForm, WorkingForm = workingForm, Order = i
                };
                _applicationTestDbContext.DesignShopWorkingForm.Add(designShopWorkingForm);
                if (i == 4)
                {
                    _currentWorkingForm = designShopWorkingForm;
                }
            }

            _designShopWithCurrentWorkingForm.CurrentDesignShopWorkingForm = _currentWorkingForm;

            _applicationTestDbContext.SaveChanges();
        }
コード例 #2
0
        public async Task <ActionResult <List <DownloadImageViewModel> > > GetListOfImagesOfWorkingForm(Guid dswfId)
        {
            // Check if the DesignShopWorkingForm exists
            if (!DesignShopWorkingFormExists(dswfId))
            {
                _logger.LogError($"Unknown DesignShopWorkingForm, asked for id {dswfId}");
                return(NotFound());
            }

            _logger.LogTrace($"Searching for images belonging to DesignShopWorkingForm with id {dswfId}.");

            DesignShopWorkingForm designShopWorkingForm = await _context.DesignShopWorkingForm
                                                          .Where(dswf => dswf.Id == dswfId)
                                                          .Include(dswf => dswf.UploadedImages)
                                                          .FirstOrDefaultAsync();

            var listOfImages = designShopWorkingForm.UploadedImages.Select(image => new DownloadImageViewModel()
            {
                Id = image.Id, DateTime = image.UploadDateTime
            }).ToList();

            _logger.LogTrace($"Found {listOfImages.Count} images for DesignShopWorkingForm with id {dswfId}");
            return(listOfImages);
        }