Ejemplo n.º 1
0
        public void GetMainByLinkedObject_Ok_Test()
        {
            var picture = _context.Pictures.First(p => p.IsMain);
            var result  = _pictureOperations.GetMainByLinkedObject(LinkedObjectType.Activity, picture.LinkedObjectId).Result;

            Assert.AreEqual(picture.Id, result.Id);
        }
Ejemplo n.º 2
0
        private async Task <List <ActivityViewModelShortGet> > ViewModelsFromEntities(IEnumerable <Activity> activities)
        {
            var result = Mapper.Map <IEnumerable <ActivityViewModelShortGet> >(activities).ToList();

            Stopwatch stopwatch = new Stopwatch();

            foreach (var viewModel in result)
            {
                stopwatch.Reset();
                stopwatch.Start();
                var picture = (await _pictureOperations.GetMainByLinkedObject(LinkedObjectType.Activity, viewModel.Id));
                Debug.WriteLine("_pictureOperations.GetMainByLinkedObject: " + stopwatch.Elapsed.TotalMilliseconds);

                var pictureViewModel = Mapper.Map <PictureViewModelShortGet>(picture);
                if (pictureViewModel != null)
                {
                    pictureViewModel.Url = Url.Content($"~/api/picture/{picture.Id}");
                }
                viewModel.MainPicture = pictureViewModel;
            }
            Debug.WriteLine("FOREACH: " + stopwatch.Elapsed.TotalMilliseconds);
            return(result);
        }