public ActionResult <CategoryDetailsViewModel> Details(int id, TranslationLanguage?language = null)
        {
            var vm = this.manager.GetQueryById(id)
                     .Select(CategoryDetailsViewModel.FromEntity(language ?? base.AppSettings.DefaultLanguage))
                     .FirstOrDefault();

            return(vm);
        }
        public ActionResult <IEnumerable <CategoryDetailsViewModel> > Index(ISearchCategoryModel search)
        {
            var vm = this.manager.SearchProductCategory(search)
                     .Select(CategoryDetailsViewModel.FromEntity(search.Language ?? base.AppSettings.DefaultLanguage))
                     .ToArray();

            return(vm);
        }
        public async Task <ActionResult <OkObjectViewModel <CategoryDetailsViewModel> > > Update(UpdateCategoryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(new BadRequestViewModel <ModelStateError>(ModelState.GetErrors())));
            }

            var result = await this.manager.UpdateProductCategoryAsync(model);

            if (!result.Succeeded)
            {
                AddManagerErrorsToModelState(result.Errors);
                return(new BadRequestObjectResult(new BadRequestViewModel <ModelStateError>(ModelState.GetErrors())));
            }

            var vm = this.manager.GetQueryById(result.Model.Id)
                     .Select(CategoryDetailsViewModel.FromEntity(AppSettings.DefaultLanguage))
                     .FirstOrDefault();

            base.Response.StatusCode = (int)HttpStatusCode.Created;
            return(new OkObjectViewModel <CategoryDetailsViewModel>("Success", vm));
        }