Exemplo n.º 1
0
        private async Task <DraftLawCategory> GetExistingCategoryAsync(NewDraftLawRequestModel model)
        {
            DraftLawCategory category = null;

            if (model.CategoryId.HasValue)
            {
                category = await _draftLawCategoryRepository.GetByIdAsync(model.CategoryId.Value);
            }

            if (category == null && !string.IsNullOrWhiteSpace(model.CategoryName))
            {
                category = await _draftLawCategoryRepository.GetByNameAsync(model.CategoryName);
            }

            if (category == null)
            {
                throw new ValidationException("Couldn't find category");
            }

            return(category);
        }
Exemplo n.º 2
0
 public async Task<DraftLawCategory> AddAsync(DraftLawCategory category)
 {
     return await _repository.AddAsync(category);
 }
 public async Task <DraftLawCategory> SaveNew(DraftLawCategory model)
 {
     return(await _service.AddAsync(model));
 }