示例#1
0
        public ResponseModel GuardarMasivo(NotificacionViewModel model)
        {
            var      rm    = new ResponseModel();
            DateTime fecha = DateTime.Now;

            try
            {
            }catch (Exception)
            {
            }

            return(rm);
        }
示例#2
0
        public ResponseModel Guardar(NotificacionViewModel model)
        {
            var      rm    = new ResponseModel();
            DateTime fecha = DateTime.Now;

            try
            {
                using (var ctx = new ContextoAplicacion())
                {
                    var notificacion = new Notificacion()
                    {
                        //notificacion.NotificacionId = model.NotificacionId;
                        TITULO = model.TITULO,
                        CUERPO_NOTIFICACION = model.CUERPO_NOTIFICACION,
                        PRIORIDAD           = 3,
                        FECHA = fecha
                    };

                    var newNotification = ctx.CTE_NOTIFICACION.Add(notificacion);
                    ctx.Entry(notificacion).State = EntityState.Added;

                    var clienteNotificacion = new CTE_NOTIFICACION_CLIENTE()
                    {
                        CuentaUsuarioId = model.CuentaUsuarioId,
                        NotificacionId  = newNotification.NotificacionId,
                        FECHA_LECTURA   = fecha,
                        LEIDA           = false
                    };

                    var newClienteNotifica = ctx.CTE_NOTIFICACION_CLIENTE.Add(clienteNotificacion);
                    ctx.Entry(clienteNotificacion).State = EntityState.Added;
                    ctx.SaveChanges();
                    //return Json(new { success = true });
                    rm.SetResponse(true);

                    //var clientes = new SelectList(db.CTE_CUENTA_USUARIO.ToList(), "CuentaUsuarioId", "NOMBRE_USUARIO");
                    //ViewData["Clientes"] = clientes;
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(rm);
        }