public async Task <ActionResult> DeletePatient(Guid patientId)
        {
            // add error handling
            var command = new DeletePatientCommand(patientId);
            await _mediator.Send(command);

            return(NoContent());
        }
        /// <summary>
        /// 删除患者信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <Unit> Handle(DeletePatientCommand request, CancellationToken cancellationToken)
        {
            await _patientRepository.SoftDeleteAsync(request.Id);

            await _patientRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);

            return(new Unit());
        }
예제 #3
0
        public CommandResult DeleteById(Guid id)
        {
            var command = new DeletePatientCommand
            {
                IdPatient = id
            };

            var result = (CommandResult)_handler.Handle(command);

            return(result);
        }
예제 #4
0
        public ICommandResult Handle(DeletePatientCommand command)
        {
            var patient = _repository.GetPatient(command.IdPatient);

            if (patient == null)
            {
                return(new CommandResult(false, "Paciente não encontrado", Notifications));
            }

            _repository.Delete(patient.Id);

            return(new CommandResult(true, "Paciente excluído com sucesso!", true));
        }
예제 #5
0
        protected void actionPatient_Command(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "delete")
            {
                Label id = (Label)listPatients.Items[e.Item.ItemIndex].FindControl("idPatient");

                String idString = id.Text;

                int idInt = Convert.ToInt32(idString);

                Patient patientDelete = new Patient(idInt);

                DeletePatientCommand cmd = new DeletePatientCommand(patientDelete);

                try
                {
                    cmd.execute();
                    patientDeleted = cmd.getAnswer();
                    if (patientDeleted._Error == Registry.RESULTADO_CODIGO_BIEN)
                    {
                        string script = "BootAlertTrue();";
                        ScriptManager.RegisterStartupScript(this, GetType(),
                                                            "ServerControlScript", script, true);
                    }
                }
                catch (Exception ex)
                {
                    string script = "BootAlertFalse();";
                    ScriptManager.RegisterStartupScript(this, GetType(),
                                                        "ServerControlScript", script, true);

                    throw ex;
                }
            }
            else if (e.CommandName == "modifyInfo")
            {
                Label id = (Label)listPatients.Items[e.Item.ItemIndex].FindControl("idPatient");

                String idString = id.Text;

                Response.Redirect("EditPatientInformation.aspx?patiendID=" + idString);
            }
            else if (e.CommandName == "viewDiagnosis")
            {
                Label id = (Label)listPatients.Items[e.Item.ItemIndex].FindControl("idPatient");

                String idString = id.Text;

                Response.Redirect("ConsultDiagnosis.aspx?patiendID=" + idString);
            }
        }
예제 #6
0
        public async Task <DeletePatientCommandResult> Handle(DeletePatientCommand request, CancellationToken cancellationToken)
        {
            var patient = await _context.Patients.SingleAsync(p => p.Id.Equals(request.Id), cancellationToken);

            patient.AddDomainEvent(new PatientDeletedEvent(patient));
            _context.Patients.Remove(patient);
            await _context.SaveChangesAsync(cancellationToken);

            await _mediator.Publish(new PatientDeletedEvent(patient), cancellationToken);

            return(new DeletePatientCommandResult
            {
                Id = request.Id,
                IsDeleted = true,
                Message = $"Patient with Id {request.Id} is deleted successfully"
            });
        }
예제 #7
0
        public async Task <ActionResult <Patient> > DeletePatient(int id)
        {
            var query  = new DeletePatientCommand(id);
            var result = await _mediator.Send(query);

            return(result != null ? (ActionResult)Ok(result) : NotFound());

            //var model = await _repository.SelectById<Patient>(id);

            //if (model == null)
            //{
            //    return NotFound();
            //}

            //await _repository.DeleteAsync<Patient>(model);

            //return model;
        }
        public async Task DeletePatientCommand_Deletes_Patient_From_Db()
        {
            // Arrange
            var fakePatientOne = new FakePatient {
            }.Generate();

            await InsertAsync(fakePatientOne);

            var patient = await ExecuteDbContextAsync(db => db.Patients.SingleOrDefaultAsync());

            var patientId = patient.PatientId;

            // Act
            var command         = new DeletePatientCommand(patientId);
            var patientReturned = await SendAsync(command);

            await SendAsync(command);

            var patients = await ExecuteDbContextAsync(db => db.Patients.ToListAsync());

            // Assert
            patients.Count.Should().Be(0);
        }
예제 #9
0
        public async Task <ActionResult> DeletePatient([FromBody] DeletePatientCommand command)
        {
            var patient = await Mediator.Send(command);

            return(Ok(patient));
        }
예제 #10
0
        public async Task <IActionResult> DeleteAsync(DeletePatientCommand command)
        {
            await _mediator.Send(command);

            return(Success());
        }
        public async Task <ActionResult <BaseResponse <Patient> > > DeletePatient(DeletePatientCommand command)
        {
            var result = await _mediator.Send(command);

            return(Ok(result));
        }