Пример #1
0
        public async Task <Unit> Handle(DeletePerson request, CancellationToken cancellationToken)
        {
            Person person = await ctx.Persons.SingleOrDefaultAsync(v => v.Id == request.Id);

            if (person == null)
            {
                throw new Exception("Record does not exist");
            }
            ctx.Persons.Remove(person);
            await ctx.SaveChangesAsync();

            return(Unit.Value);
        }
        public async Task <IActionResult> Delete(DeletePerson request)
        {
            await mediator.Send(request);

            return(Ok());
        }