public async Task <Result <DeleteAppointmentReason> > Handle(DeleteAppointmentCommand request, CancellationToken cancellationToken)
        {
            using (_commontUnitOfWork)
            {
                try
                {
                    var result = await _commontUnitOfWork.Repository <PatientAppointment>()
                                 .Get(x => x.Id == request.AppointmentId && x.DeleteFlag == false).ToListAsync();

                    if (result.Count > 0)
                    {
                        result[0].DeleteFlag = true;

                        _commontUnitOfWork.Repository <PatientAppointment>().Update(result[0]);
                        await _commontUnitOfWork.SaveAsync();
                    }

                    return(Result <DeleteAppointmentReason> .Valid(new DeleteAppointmentReason()
                    {
                        Message = "Successfully deleted appointment"
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e, $"Could not delete appointmentId: {request.AppointmentId}");
                    return(Result <DeleteAppointmentReason> .Invalid($"Could not delete appointmentId: {request.AppointmentId}"));
                }
            }
        }
        public async Task <IActionResult> Delete(long appointmentId)
        {
            var command = new DeleteAppointmentCommand(appointmentId);
            await mediator.Send(command);

            return(NoContent());
        }
Exemple #3
0
        public async Task <IActionResult> Delete([FromForm] DeleteAppointmentCommand command)
        {
            await Mediator.Send(command);

            return(this.Redirect($"/User/Profile/{command.UserId}"));
        }
Exemple #4
0
        public async Task <ActionResult> DeleteAppointment([FromBody] DeleteAppointmentCommand command)
        {
            var appointment = await Mediator.Send(command);

            return(Ok(appointment));
        }
Exemple #5
0
        public async Task <ActionResult <bool> > DeletePostAsync([FromBody] DeleteAppointmentCommand command)
        {
            var result = await _mediator.Send(command);

            return(Ok(ResponseWrapper.CreateOkResponseWrapper(result)));
        }
Exemple #6
0
 public async Task <IActionResult> Delete(DeleteAppointmentCommand command)
 {
     return(Ok(await bus.Send(command)));
 }