コード例 #1
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);
        }