Ejemplo n.º 1
0
        DeleteIncident(AppShared.Incident.Delete.Query query)
        {
            var response = await Mediator.Send(query);

            if (!response.Succeeded)
            {
                return(NotFound(response));
            }
            return(Ok(response));
        }
Ejemplo n.º 2
0
            public async Task <ApiResponse <AppShared.Incident.Delete.Result> > Handle(AppShared.Incident.Delete.Query request, CancellationToken cancellationToken)
            {
                var item = await heroContext.Incidents.Where(c => c.Id == request.Id).FirstOrDefaultAsync();

                if (item == null)
                {
                    return(ApiResponse <AppShared.Incident.Delete.Result> .FailureFrom("Incident not found"));
                }

                heroContext.Incidents.Remove(item);

                return(ApiResponse <AppShared.Incident.Delete.Result> .SuccessFrom(new AppShared.Incident.Delete.Result()
                {
                    IsSuccess = true
                }));
            }