public async Task <IActionResult> AddCategory([FromForm] RegisterCategoryRequest request) { var command = new RegisterCategoryCommand(request.NameEng, request.Name, request.Categorize, request.ImageUrl); return(await HandleActionResultFor(command)); }
public async Task <IHttpActionResult> PostAsync([FromBody] NewCategory body) { var command = new RegisterCategoryCommand(body.Title); _categoryManager.Register(command); if (_domainNotification.HasNotifications()) { _domainNotification.Notify().ToList().ForEach(error => ModelState.AddModelError(error.Key, error.Value)); return(await Task.FromResult(BadRequest(ModelState))); } return(await Task.FromResult(Ok(_categoryRegistered.Notify()))); }
public CategoryHandlerTest() { mockMapper = new Mock <IMapper>(); mockMediator = new Mock <IMediatorHandler>(); mockNotification = new Mock <DomainNotificationHandler>(); var mockRepository = new Mock <ICategoryRepository>(); categoryViewModel = new CategoryViewModel(); registerCategoryCommand = new RegisterCategoryCommand(Guid.NewGuid(), "Teste"); categoryController = new CategoryController( mockNotification.Object, mockRepository.Object, mockMapper.Object, mockMediator.Object); }