private async Task CascadeLogicalDeleteAsync(Domain.Entities.Host host, CancellationToken cancellationToken) { host.User.IsDeleted = true; foreach (long id in host.ApartmentsForRental.Where(a => !a.IsDeleted).Select(a => a.Id).ToList()) { var command = new DeleteApartmentCommand() { ApartmentId = id }; await this.mediator.Send(command, cancellationToken).ConfigureAwait(false); } }
public async Task <IActionResult> Delete(long id) { if (await authService.CheckIfBanned(this.User).ConfigureAwait(false)) { return(this.Forbid()); } var command = new DeleteApartmentCommand() { ApartmentId = id }; await this.mediator.Send(command).ConfigureAwait(false); return(this.Ok()); }
public async Task <ActionResult> Delete([FromBody] DeleteApartmentCommand cmd) { var result = await mediator.Send(cmd); return(new JsonResult(result)); }