Пример #1
0
        public async Task <AuthenticationResult> UpdateAsync(UserIndexViewModel model)
        {
            CoreValidator.ThrowIfAnyNull(model, model?.Id);

            var user = await this.userManager.FindByIdAsync(model.Id);

            var emailUpdated = user.Email != model.Email;

            user.FirstName      = model.FirstName;
            user.LastName       = model.LastName;
            user.EmailConfirmed = emailUpdated ? false : user.EmailConfirmed;
            user.Email          = model.Email;
            user.Username       = model.Username;

            var result = await this.userManager.UpdateAsync(user);

            return(result);
        }
Пример #2
0
        public async Task <ProductDetailsViewModel> GetAsync(string id)
        {
            var product = await this.productRepository.GetAsync(id);

            CoreValidator.ThrowIfNull(product);
            this.EnsureNotDeleted(product);

            var category = await this.categoryRepository.GetAsync(product.CategoryId);

            var pictures = await this.pictureRepository
                           .FilterAsync(nameof(Picture.EntityId), product.Id);

            CoreValidator.ThrowIfAnyNull(category, pictures);

            var model = this.customMapper.Map <Product, ProductDetailsViewModel>(product);

            model.CategoryName = category.Name;
            model.Pictures     = pictures
                                 .Select(pic => this.customMapper.Map <Picture, PictureConciseViewModel>(pic));

            return(model);
        }