public async Task <IActionResult> Delete(Guid id) { var command = new DeleteInterestCommand(id); var result = await Mediator.Send(command); return(await ResponseBase(result)); }
public async Task <BaseResponse <string> > Handle(DeleteInterestCommand request, CancellationToken cancellationToken) { var interest = await _applicationDbContext.Interest.FindAsync(request.Id); var response = new BaseResponse <string>(); if (interest == null) { response.SetValidationErrors(new [] { "Interest Not Found!" }); return(response); } _applicationDbContext.Interest.Remove(interest); await _applicationDbContext.SaveChangesAsync(cancellationToken); response.SetIsOk("Interest has been removed!"); return(response); }
public InterestsViewModel(IApplicationService applicationService, IFeaturesService featuresService) { ApplicationService = applicationService; var interests = new ReactiveList <Interest>(); Interests = interests; DeleteInterestCommand = ReactiveCommand.Create(); DeleteInterestCommand.OfType <Interest>().Subscribe(ApplicationService.Account.Interests.Remove); GoToStumbleInterestCommand = ReactiveCommand.Create(); GoToStumbleInterestCommand.OfType <Interest>().Subscribe(x => { var vm = CreateViewModel <StumbleViewModel>(); vm.Interest = x; ShowViewModel(vm); }); GoToAddInterestCommand = ReactiveCommand.Create(); GoToAddInterestCommand.Subscribe(_ => { if (ApplicationService.Account.Interests.Count() >= 3 && !featuresService.ProEditionEnabled) { var vm = CreateViewModel <PurchaseProViewModel>(); ShowViewModel(vm); } else { var vm = CreateViewModel <AddInterestViewModel>(); ShowViewModel(vm); } }); this.WhenActivated(d => { interests.Reset(ApplicationService.Account.Interests.Query.OrderBy(x => x.Keyword)); }); }