private void handleDeleteTableViewRowAction(UITableViewRowAction _, NSIndexPath indexPath) { SwipeToDeleteWasUsed?.Invoke(this, EventArgs.Empty); var timeEntry = (TimeEntryViewModel)GetItemAt(indexPath); DeleteTimeEntryCommand.Execute(timeEntry); }
public async Task <IHttpActionResult> Delete(DeleteTimeEntryCommand command) { try { await timeEntryService.DeleteTimeEntry(command); return(Ok()); } catch (ValidationException ex) { return(BadRequest(ex.Message)); } catch (AuthorizationException) { return(StatusCode(System.Net.HttpStatusCode.Forbidden)); } }
async Task ITimeEntryService.DeleteTimeEntry(DeleteTimeEntryCommand command) { var currentPrincipal = await currentUserResolver.ResolveCurrentClaimsPrincipalAsync(); await authorizationService.AuthorizeResourceType(currentPrincipal, Operation.Delete, typeof(TimeEntry)); Check.NotNull(command, errorMessage: "Command can not be null."); await validationService.Validate(command); var existingTimeEntry = await timeEntryRepository.GetTimeEntryById(command.TimeEntryId); if (existingTimeEntry == null) { return; } await authorizationService.AuthorizeResource(currentPrincipal, Operation.Delete, existingTimeEntry); await timeEntryRepository.DeleteTimeEntry(existingTimeEntry); }
private void handleDeleteTableViewRowAction(UITableViewRowAction _, NSIndexPath indexPath) { var timeEntry = (TimeEntryViewModel)GetItemAt(indexPath); DeleteTimeEntryCommand.Execute(timeEntry); }