/// <summary>
        /// Get category model to update
        /// </summary>
        /// <param name="slug"></param>
        /// <returns></returns>
        /// TODO Add access check
        public async Task <CategoryUpdateModel> Get(string slug)
        {
            var entity = await _providerCategoryRepository.GetFirst(x => x.Slug == slug);

            if (entity == null)
            {
                throw new EntityNotFoundException(slug, typeof(ProviderCategory), "Can not find category");
            }

            var model = new CategoryUpdateModel
            {
                Slug         = entity.Slug,
                Translations = entity.Translations.Select(x =>
                                                          new CategoryTranslationUpdateModel
                {
                    Description  = x.Description,
                    IsDefault    = x.IsDefault,
                    LanguageCode = x.LanguageCode,
                    Name         = x.Name
                }).ToList()
            };

            return(model);
        }
        /// <summary>
        /// Create new provider
        /// </summary>
        /// <param name="model">new provider model</param>
        /// <returns></returns>
        public async Task <IdNameModel> Create(ProviderUpdateModel model)
        {
            if (model == null)
            {
                throw new ModelDamagedException(nameof(model), "can not be empty");
            }

            var user = await GetCurrentUser();

            if (!(await _appUserManager.IsInRoleAsync(user, "MANAGER")) && !(await _appUserManager.IsInRoleAsync(user, "ADMIN")))
            {
                throw new NotEnoughRightsException();
            }

            if (string.IsNullOrWhiteSpace(model.Slug))
            {
                throw new ModelDamagedException(nameof(model.Slug), "can not be empty");
            }

            model.Slug = model.Slug.ToLower();

            if (string.IsNullOrWhiteSpace(model.Category))
            {
                throw new ModelDamagedException(nameof(model.Category), "can not be empty");
            }

            if (model.Translations == null || !model.Translations.Any())
            {
                throw new ModelDamagedException(nameof(model.Translations), "can not be null or empty");
            }

            var isSlugExists = (await _providerRepository.Count(x => x.Slug == model.Slug && x.State == MREntityState.Active)) > 0;

            if (isSlugExists)
            {
                throw new MRSystemException($"Provider with slug {model.Slug} already exists");
            }

            var category = await _providerCategoryRepository.GetFirst(x => x.Slug == model.Category);

            if (category == null)
            {
                throw new EntityNotFoundException(model.Category, typeof(ProviderCategory));
            }

            var entity = _mapper.Map <Provider>(model);

            entity.Owner    = _mapper.Map <ProviderOwner>(user);
            entity.Category = new ProviderProviderCategory
            {
                CategoryId = category.Id,
                Slug       = category.Slug
            };
            entity.Tags = new List <ProviderProviderTag>();

            entity.Workers = new List <ProviderWorker>
            {
                new ProviderWorker
                {
                    Roles = new List <ProviderWorkerRole>
                    {
                        ProviderWorkerRole.ANALYTICS,
                        ProviderWorkerRole.DEVELOPER,
                        ProviderWorkerRole.MANAGER,
                        ProviderWorkerRole.OWNER,
                        ProviderWorkerRole.USER_MANAGER
                    },
                    UserEmail = _userEmail,
                    UserId    = _userId
                }
            };

            // set avatar
            if (entity.Avatar != null)
            {
                var image = await _imageOriginBucket.MoveFrom(_imageTmpBucket.BucketFullPath, model.Avatar.Key);

                if (image != null && image.IsSuccess)
                {
                    entity.Avatar.Url = image.Url;
                }
            }

            // set background
            if (entity.Background != null)
            {
                var image = await _imageOriginBucket.MoveFrom(_imageTmpBucket.BucketFullPath, model.Background.Key);

                if (image != null && image.IsSuccess)
                {
                    entity.Background.Url = image.Url;
                }
            }

            var result = await _providerRepository.Insert(entity);

            return(new IdNameModel
            {
                Id = result.Id,
                Name = result.Name
            });
        }