public void Handle(CreateAlertCommand command)
        {
            var alert1 = new Alert(command.Id, command.AdresLine1, command.AdresLine2, command.ZipCode, command.LoginName);

            _alertRepository.Add(alert1);
            _eventBus.Publish(new AlertCreatedEvent(command.Id, command.AdresLine1, command.AdresLine2, command.ZipCode, command.LoginName));
        }
示例#2
0
        public IActionResult Post()
        {
            Alert            alert          = new Alert();
            List <Condition> condition_list = new List <Condition>();

            alert.Name      = Request.Form["nombre_alerta"];
            alert.AlertType = Request.Form["tipo_alerta"];
            alert.Frecuency = Int32.Parse(Request.Form["frecuencia_alerta"]);
            string mails = Request.Form["correos_notificacion"];

            alert.Mailto  = mails.Split(";").ToList();
            alert.Message = Request.Form["mensaje_alerta"];
            for (int i = 1; i <= Int32.Parse(Request.Form["conditions_number"]); i++)
            {
                Condition condition = new Condition();
                condition.StationId  = Request.Form["estacion_alerta" + i.ToString()];
                condition.SensorId   = Request.Form["sensor_alerta" + i.ToString()];
                condition.Comparison = Request.Form["condicion_alerta" + i.ToString()];
                condition.Threshold  = Int32.Parse(Request.Form["threshold_alerta" + i.ToString()]);
                condition_list.Add(condition);
            }
            alert.Conditions = condition_list;
            bool result = _AlertRepository.Add(alert);

            setTempData(result, "createResult");
            return(Redirect("index"));
        }
        public async Task <bool> Handle(ReceiveAlertCommand request, CancellationToken cancellationToken)
        {
            _alertRepository.Add(new Domain.AggregatesModel.AlertAggregate.Alert(
                                     request.Alerta,
                                     request.Host,
                                     request.Prioridade,
                                     request.Ambiente,
                                     request.Corretora,
                                     request.Equipe,
                                     request.Email_app,
                                     request.Criticidade,
                                     request.Status,
                                     Guid.NewGuid()));

            var result = await _alertRepository.UnitOfWork
                         .SaveEntitiesAsync(cancellationToken);

            if (result)
            {
                var team = await _teamRepository.GetByEmailAsync(request.Email_app);

                var phone = team.GetMemberToCall();

                if (phone == null)
                {
                    var manager = await _managerRepository.GetAsync(team.ManagerId);

                    phone = Convert.ToInt64(manager.Phone);
                }

                var code = await _followupAdapter.MakeCall(55, (long)phone);

                return(!string.IsNullOrEmpty(code));
            }
            else
            {
                return(false);
            }
        }