Esempio n. 1
0
        private void ReassignProfessionalMail(AssignServiceDetail assignServiceDetail, int detailCount)
        {
            var result        = _assignServiceDomainService.GetAssignServiceById(assignServiceDetail.AssignServiceId);
            var assingService = result.Result;

            if (assingService == null)
            {
                return;
            }

            var patientResult        = _patientDomainService.GetPatientById(assingService.PatientId);
            var serviceResult        = _serviceDomainService.GetServiceById(assingService.ServiceId);
            var service              = serviceResult.Result;
            var patient              = patientResult.Result;
            var professionalResult   = _professionalDomainService.GetProfessionalById(assignServiceDetail.ProfessionalId);
            var professional         = professionalResult.Result;
            var professionalFullName = $"{professional.FirstName} {professional.SecondName} {professional.Surname} {professional.SecondSurname}";
            var patientFullName      = $"{patient.FirstName} {patient.SecondName} {patient.Surname} {patient.SecondSurname}";
            var mailMessage          = new MailMessage
            {
                Body = string.Format(AdomMailContent.ProfessionalReasigmentMail,
                                     professionalFullName,
                                     patient.Document,
                                     patientFullName,
                                     service.Name,
                                     detailCount),

                Subject = "Cambios en tus servicios - ADOM",
                To      = new MailAccount(professional.FirstName, professional.Email)
            };

            _mailService.SendMail(mailMessage);
        }
Esempio n. 2
0
        public ServiceResult <AssignServiceDetail> Update(AssignServiceDetail assignServiceDetail)
        {
            var updated = repository.Update(assignServiceDetail);

            return(new ServiceResult <AssignServiceDetail>
            {
                Success = true,
                Result = updated
            });
        }
        public AssignServiceDetail Update(AssignServiceDetail assignServiceDetail)
        {
            var id = _connection.Query <int>(AssignServiceDetailQuerys.Update,
                                             new
            {
                assignServiceDetail.AssignServiceId,
                assignServiceDetail.AssignServiceDetailId,
                StateAssignServiceDetailId = assignServiceDetail.StateId,
                assignServiceDetail.ProfessionalId,
                @DateVisitP = assignServiceDetail.DateVisit,
                Observation = assignServiceDetail.Observation?.ToUpper(),
                assignServiceDetail.PaymentType,
                assignServiceDetail.ReceivedAmount,
                assignServiceDetail.OtherAmount,
                assignServiceDetail.Pin,
                assignServiceDetail.Verified,
                assignServiceDetail.VerifiedBy
            }, commandType: CommandType.StoredProcedure).Single();

            assignServiceDetail.AssignServiceDetailId = id;
            return(assignServiceDetail);
        }
 public ServiceResult <AssignServiceDetail> Update(AssignServiceDetail assignServiceDetail)
 {
     return(service.Update(assignServiceDetail));
 }
Esempio n. 5
0
        public ServiceResult <AssignServiceDetail> Put(int id, [FromBody] IEnumerable <AssignServiceDetail> models)
        {
            ServiceResult <AssignServiceDetail> result = new ServiceResult <AssignServiceDetail>();
            var errorList                     = new List <string>();
            var isReassignment                = false;
            var reasigmentDetailCount         = 0;
            AssignServiceDetail currentDetail = null;

            if (models.Count() == 0)
            {
                errorList.Add("Seleccione por lo menos una visita");
                result.Errors = errorList.ToArray();
                return(result);
            }
            foreach (var model in models)
            {
                if (string.IsNullOrEmpty(model.DateVisit) && model.StateId == 2)
                {
                    errorList.Add("En la visita #" + model.Consecutive + " es necesario ingresar la fecha de visita");
                    result.Success = false;
                    break;
                }
                if (string.IsNullOrEmpty(model.DateVisit) && model.Verified)
                {
                    errorList.Add("En la visita #" + model.Consecutive + " es necesario ingresar la fecha de visita");
                    result.Success = false;
                    break;
                }

                DateTime date;
                DateTime.TryParseExact(model.DateVisit, "dd-MM-yyyy", CultureInfo.InvariantCulture,
                                       DateTimeStyles.None, out date);
                if (date > DateTime.Today && model.StateId == 2)
                {
                    errorList.Add("En la visita #" + model.Consecutive + " la fecha de visita es mayor a hoy");
                    result.Success = false;
                    break;
                }
                var validatorResult = _validator.Validate(model);

                if (validatorResult.IsValid)
                {
                    try
                    {
                        var currentDetailResult = _appService.GetAssignServiceDetailById(model.AssignServiceDetailId);
                        currentDetail = currentDetailResult.Result;
                        result        = _appService.Update(model);
                        if (currentDetail.ProfessionalId != model.ProfessionalId)
                        {
                            reasigmentDetailCount++;
                            isReassignment = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        result = new ServiceResult <AssignServiceDetail>();
                        errorList.Add(ex.Message);
                        result.Success = false;
                    }
                }
                else
                {
                    result         = new ServiceResult <AssignServiceDetail>();
                    errorList      = validatorResult.GetErrors().ToList();
                    result.Success = false;
                }
            }
            if (isReassignment && currentDetail != null)
            {
                ReassignProfessionalMail(currentDetail, reasigmentDetailCount);
            }
            result.Errors = errorList.ToArray();
            return(result);
        }