Ejemplo n.º 1
0
        public object GetTiposNotificacionesVigenciasAplicaciones()
        {
            var listaDeTipos = new
            {
                TipoNotificacion = new List <KeyValuePar>(),
                TipoVigencia     = new List <KeyValuePar>(),
                Aplicaciones     = new List <KeyValuePar>()
            };

            listaDeTipos.TipoNotificacion.AddRange(KeyValuePar.ListFrom <Enumeraciones.TiposNotificaciones>());
            listaDeTipos.TipoVigencia.AddRange(KeyValuePar.ListFrom <Enumeraciones.TipoVigencia>());
            listaDeTipos.Aplicaciones.AddRange(clienteRepo.GetClientes().Select(s => new KeyValuePar {
                Key = s.Id, Value = s.Name
            }).ToList());
            return(listaDeTipos);
        }
Ejemplo n.º 2
0
        internal NotificacionModel CreateNotificacion(NotificacionModel notificacionModel)
        {
            notificacionModel.FechaCreacion = DateTime.Now;

            var app = notificacionModel.AplicacionId > 0
                          ? _ctx.Clients.FirstOrDefault(s => s.Id == notificacionModel.AplicacionId)
                          : _ctx.Clients.FirstOrDefault(s => s.Name == notificacionModel.Aplicacion);

            if (app != null)
            {
                notificacionModel.Aplicacion   = app.Name;
                notificacionModel.AplicacionId = app.Id;
            }

            notificacionModel.Tipo         = KeyValuePar.GetDescriptionFromEnumValue((Enumeraciones.TiposNotificaciones)notificacionModel.IdTipo);
            notificacionModel.TipoVigencia = KeyValuePar.GetDescriptionFromEnumValue((Enumeraciones.TipoVigencia)notificacionModel.IdTipo);

            var result = _ctx.Notificacions.Add(Notificacion.FillEntitie(notificacionModel));

            _ctx.SaveChanges();
            saveNotificationLog(result, notificacionModel.Usuarios);
            notificacionModel.NotificacionId = result.NotificacionId;
            return(notificacionModel);
        }
Ejemplo n.º 3
0
        internal NotificacionModel UpdateNotificacion(NotificacionModel notificacionModel)
        {
            var app = notificacionModel.AplicacionId > 0
                        ? _ctx.Clients.FirstOrDefault(s => s.Id == notificacionModel.AplicacionId)
                        : _ctx.Clients.FirstOrDefault(s => s.Name == notificacionModel.Aplicacion);

            if (app != null)
            {
                notificacionModel.Aplicacion   = app.Name;
                notificacionModel.AplicacionId = app.Id;
            }

            notificacionModel.Tipo         = KeyValuePar.GetDescriptionFromEnumValue((Enumeraciones.TiposNotificaciones)notificacionModel.IdTipo);
            notificacionModel.TipoVigencia = KeyValuePar.GetDescriptionFromEnumValue((Enumeraciones.TipoVigencia)notificacionModel.IdTipo);


            var oldNotificacion = _ctx.Notificacions.FirstOrDefault(s => s.NotificacionId == notificacionModel.NotificacionId);
            var result          = Notificacion.UpdateFromModel(oldNotificacion, notificacionModel);

            _ctx.SaveChanges();
            notificacionModel.NotificacionId = result.NotificacionId;
            saveNotificationLog(result, notificacionModel.Usuarios);
            return(notificacionModel);
        }
Ejemplo n.º 4
0
 internal List <KeyValuePar> GetTiposAplicaciones()
 {
     return(KeyValuePar.ListFrom <ApplicationTypes>());
 }