Example #1
0
        public IActionResult Index()
        {
            var testMode = _userLogic.GetUserByEmail(User.Identity.Name).FullName.Contains("TEST");

            var users = testMode
                ? _userLogic.GetAllUsers().Where(user => user.Role == 0 && user.FullName.Contains("TEST"))
                : _userLogic.GetAllUsers().Where(user => user.Role == 0 && !user.FullName.Contains("TEST"));

            var model = new AdminIndexViewModel()
            {
                Users           = users.Select(user => new AdminUserViewModel(user)).ToList(),
                OfferedServices = new List <AdminOfferedServiceViewModel>(),
                UsedServices    = new List <AdminUsedServiceViewModel>()
            };

            foreach (var offeredService in _offeredServiceLogic.GetAllOfferedServices().Where(os => testMode ? os.Name.Contains("TEST") : !os.Name.Contains("TEST")))
            {
                var provider   = new UserViewModel(_userLogic.GetUserById(offeredService.ProviderId));
                var amountSold = _usedServiceLogic.GetUsedServicesByOfferdServiceId(offeredService.Id).Count();
                model.OfferedServices.Add(new AdminOfferedServiceViewModel(offeredService, provider, amountSold));
            }

            foreach (var usedService in _usedServiceLogic.GetAllUsedServices().Where(us => testMode ? _userLogic.GetUserById(us.ConsumerId).FullName.Contains("TEST") : !_userLogic.GetUserById(us.ConsumerId).FullName.Contains("TEST")))
            {
                var consumer       = new UserViewModel(_userLogic.GetUserById(usedService.ConsumerId));
                var offeredService = new OfferedServiceViewModel(_offeredServiceLogic.GetOfferedServiceById(usedService.OfferedServiceId));
                model.UsedServices.Add(new AdminUsedServiceViewModel(usedService, offeredService, consumer));
            }

            return(View(model));
        }
Example #2
0
        public IActionResult Index()
        {
            var user = _userLogic.GetUserByEmail(User.Identity.Name);

            var model = new ProfileViewModel()
            {
                FirstName   = user.FirstName,
                LastName    = user.LastName,
                Email       = user.Email,
                Description = user.Description,
                OfferedServiceViewModels = new List <OfferedServiceViewModel>(),
                UsedServiceViewModels    = new List <UsedServiceViewModel>()
            };

            foreach (var offeredService in _offeredServiceLogic.GetOfferedServicesByUserId(user.Id))
            {
                var provider = new UserViewModel(_userLogic.GetUserById(offeredService.ProviderId));
                var images   = _imageLogic.GetImagesByOfferedServiceId(offeredService.Id)
                               .Select(image => image.ToString()).ToList();
                var offeredServiceViewModel = new OfferedServiceViewModel(offeredService, provider, images);

                model.OfferedServiceViewModels.Add(offeredServiceViewModel);
            }

            foreach (var usedService in _usedServiceLogic.GetUsedServicesByConsumerId(user.Id))
            {
                var reviewViewModel = _reviewLogic.GetReviewsByWriterId(user.Id)
                                      .Where(review => review.UsedServiceId == usedService.Id)
                                      .Select(review => new ReviewViewModel(review)).FirstOrDefault();

                var offeredService =
                    new OfferedServiceViewModel(
                        _offeredServiceLogic.GetOfferedServiceById(usedService.OfferedServiceId));
                var usedServiceViewModel   = new UsedServiceViewModel(usedService, offeredService, reviewViewModel);
                var consumedOfferedService = _offeredServiceLogic.GetOfferedServiceById(usedService.OfferedServiceId);
                var provider = new UserViewModel(_userLogic.GetUserById(consumedOfferedService.ProviderId));
                var images   = _imageLogic.GetImagesByOfferedServiceId(consumedOfferedService.Id)
                               .Select(image => image.ToString()).ToList();
                usedServiceViewModel.OfferedService =
                    new OfferedServiceViewModel(consumedOfferedService, provider, images);

                model.UsedServiceViewModels.Add(usedServiceViewModel);
            }

            return(View(model));
        }
Example #3
0
        public IActionResult ViewOfferedService(int offeredServiceId)
        {
            var offeredService = _offeredServiceLogic.GetOfferedServiceById(offeredServiceId);
            var provider       = new UserViewModel(_userLogic.GetUserById(offeredService.ProviderId));
            var images         = _imageLogic.GetImagesByOfferedServiceId(offeredService.Id).Select(image => image.ToString())
                                 .ToList();

            var model = new OfferedServiceViewModel(offeredService, provider, images);

            return(View(model));
        }
Example #4
0
        private WriteReviewViewModel GetOfferedServiceViewModel(int offeredServiceId)
        {
            var offeredService = _offeredServiceLogic.GetOfferedServiceById(offeredServiceId);
            var images         = _imageLogic.GetImagesByOfferedServiceId(offeredServiceId).Select(image => image.ImageAsString)
                                 .ToList();
            var provider = new UserViewModel(_userLogic.GetUserById(offeredService.ProviderId));

            var model = new WriteReviewViewModel()
            {
                OfferedService = new OfferedServiceViewModel(offeredService, provider, images)
            };

            return(model);
        }