Пример #1
0
        public async Task UpdateCategoryAsync(int id, CreateUpdateCategoryInput input)
        {
            var category = await _repository.FindAsync(id);

            if (category == null)
            {
                ExceptionBuilder.Build(HttpStatusCode.NotFound, new HttpException($"Id {id} not match category"));
            }
            await _categoryManager.SetName(input.Name, category);

            await _repository.UpdateAsync(id, category);
        }
Пример #2
0
        public async Task <StandardOutput <bool> > UpdateCategory(CreateUpdateCategoryInput input)
        {
            var responseMessage = await _categoryProvider.UpdateCategory(input);

            if (responseMessage.StateCode != Define.StateCode.OK)
            {
                return new StandardOutput <bool>
                       {
                           Entity  = false,
                           Message = $"Update category failed. Check if category Name: {input.Name} is already existed or id {input.Id} Not Found."
                       }
            }
            ;
            return(new StandardOutput <bool>
            {
                Entity = true,
                Message = "Update category succeed."
            });
        }
Пример #3
0
 public async Task <ResponseMessage <bool> > UpdateCategory(CreateUpdateCategoryInput input)
 {
     return(await SendEmptyResponseBodyRequest(Category, _http.PutAsJsonAsync, input));
 }
Пример #4
0
        public async Task CreateCategoryAsync(CreateUpdateCategoryInput input)
        {
            var category = await _categoryManager.CreateCategory(input.Name);

            await _repository.CreateAsync(category);
        }
Пример #5
0
 public async Task Update(CreateUpdateCategoryInput input)
 {
     await _categoryService.UpdateCategoryAsync(input.Id, input);
 }