Exemplo n.º 1
0
        public override Result <Patient> Update(PatientModel model)
        {
            try
            {
                Patient patient = _mapper.Map <Patient>(model);
                var     result  = _patientValidation.Validate(patient);

                if (!result.Success)
                {
                    return(result);
                }

                var resultSave = _patientDAL.Update(patient);
                if (!resultSave.Success)
                {
                    return(Result <Patient> .BuildError(resultSave.Messages));
                }

                return(Result <Patient> .BuildSuccess(patient));
            }
            catch (Exception error)
            {
                return(Result <Patient> .BuildError("Erro ao alterar o registro do paciente", error));
            }
        }
Exemplo n.º 2
0
        public ProcessResult Update(Patient newInfoPatient)
        {
            ProcessResult processResult = ValidateModel(newInfoPatient, true);

            if (processResult.Result != Extensions.BLLResult.Verified)
            {
                return(processResult);
            }
            Patient patient = Select(newInfoPatient.TcNo);

            if (patient != null && patient.Id != newInfoPatient.Id)
            {
                processResult.Errors.Add("Girilen kimlik numarasıyla başka bir hasta kaydı zaten bulunmaktadır");
                processResult.Result = Extensions.BLLResult.AlreadyFound;
                return(processResult);
            }
            DAL.Extensions.DataBaseResult result = _patientDal.Update(newInfoPatient);

            switch (result)
            {
            case DAL.Extensions.DataBaseResult.Success:
                processResult.Result = Extensions.BLLResult.Success;
                processResult.Errors.Add(Extensions.SuccessProcess);
                break;

            case DAL.Extensions.DataBaseResult.Error:
                processResult.Errors.Add(Extensions.InnerException);
                processResult.Result = Extensions.BLLResult.Error;
                break;

            case DAL.Extensions.DataBaseResult.NotFound:
                processResult.Errors.Add(Extensions.NotFound);
                processResult.Result = Extensions.BLLResult.NotFound;
                break;

            case DAL.Extensions.DataBaseResult.ServerDisable:
                processResult.Result = Extensions.BLLResult.ServerDisable;
                processResult.Errors.Add(Extensions.ServerDisable);
                break;

            case DAL.Extensions.DataBaseResult.AlreadyFound:
                break;

            case DAL.Extensions.DataBaseResult.Referanced:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(processResult);
        }