public async Task <CommandResult> Handle(RemoveMeasureCategoryCommand request, CancellationToken cancellationToken) { CustomMeasureCategory customMeasureCategory = await _measureCategoryRepository.GetCustomByIdAsync(request.MeasureCategoryId, _currentProfileId); if (customMeasureCategory == null) { return(FailureDueToCustomMeasureCategoryNotFound()); } await _measureCategoryRepository.RemoveAsync(customMeasureCategory); return(await CommitAndPublishDefaultAsync()); }
public async Task <CommandResult> Handle(RegisterMeasureCategoryCommand request, CancellationToken cancellationToken) { CustomMeasureCategory customMeasureCategory = new CustomMeasureCategory( _currentProfileId, request.Name, request.Description, request.IsFavorite ); await _measureCategoryRepository.RegisterAsync(customMeasureCategory); return(await CommitAndPublishDefaultAsync()); }
public async Task <CommandResult> Handle(UpdateMeasureCategoryCommand request, CancellationToken cancellationToken) { CustomMeasureCategory customMeasureCategory = await _measureCategoryRepository.GetCustomByIdAsync(request.MeasureCategoryId, _currentProfileId); if (customMeasureCategory == null) { return(FailureDueToCustomMeasureCategoryNotFound()); } customMeasureCategory.Update( request.Name, request.Description, request.IsFavorite ); await _measureCategoryRepository.UpdateAsync(customMeasureCategory); return(await CommitAndPublishDefaultAsync()); }
public async Task <IActionResult> GetCustomByIdAsync(Guid id) { CustomMeasureCategory customMeasureCategory = await _measureCategoryRepository.GetCustomByIdAsync(id, _currentProfileId); return(CreateResponse(customMeasureCategory)); }