public async Task <IActionResult> Putnotificacion(int id, notificacion notificacion)
        {
            if (id != notificacion.NotificacionId)
            {
                return(BadRequest());
            }

            _context.Entry(notificacion).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!notificacionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <notificacion> > Postnotificacion(notificacion notificacion)
        {
            _context.notificaciones.Add(notificacion);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getnotificacion", new { id = notificacion.NotificacionId }, notificacion));
        }
Example #3
0
        /// <summary>
        /// Actualiza la notificación.
        /// </summary>
        /// <param name="NOTIFICACION_ID"></param>
        /// <param name="NOTIFICACION_ESTADO"></param>
        public void ActualizarNotificacion(int NOTIFICACION_ID, EstadosNotificacion NOTIFICACION_ESTADO)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.notificaciones", "NOTIFICACION_ID", NOTIFICACION_ID);

                    Object n = null;

                    if (db.TryGetObjectByKey(k, out n))
                    {
                        notificacion notification = (notificacion)n;

                        notification.NOTIFICACION_ESTADO = (int)NOTIFICACION_ESTADO;

                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al actualizar notificacion.", ex);
                throw;
            }
        }
Example #4
0
        /// <summary>
        /// Inserta la notificación.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="TITLE"></param>
        /// <param name="MENSAJE"></param>
        public void InsertarNotificacion(string USR_USERNAME, string TITLE, string MENSAJE)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    notificacion notification = new notificacion();

                    notification.NOTIFICACION_ESTADO  = (int)EstadosNotificacion.Creado;
                    notification.NOTIFICACION_TITLE   = TITLE;
                    notification.NOTIFICACION_MENSAJE = MENSAJE;
                    notification.USR_USERNAME         = USR_USERNAME;
                    notification.NOTIFICACION_FECHA   = DateTime.Now;

                    db.notificaciones.AddObject(notification);

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al insertar notificacion.", ex);
                throw;
            }
        }
Example #5
0
        public ActionResult DeleteConfirmed(long id)
        {
            notificacion notificacion = db.notificacion.Find(id);

            db.notificacion.Remove(notificacion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #6
0
 public async void LimpiarNotifiacion(notificacion notificacion)
 {
     await Task.Delay(TimeSpan.FromSeconds(4)).ContinueWith(x =>
     {
         notificaciones.Remove(notificacion);
         this.StateHasChanged();
     });
 }
 public string update_notificacion(notificacion obj)
 {
     if (obj_notificacion.update_notificacion(obj))
     {
         return("U200");
     }
     else
     {
         return("U500");
     }
 }
 public string insert_notificacion(notificacion obj)
 {
     if (obj_notificacion.insert_notificacion(obj))
     {
         return("I200");
     }
     else
     {
         return("I500");
     }
 }
Example #9
0
 public ActionResult Edit([Bind(Include = "ID_Notificacion,Mensaje_Notificacion,Fecha,ID_formato,ID_DocumentoAprendiz,ID_DocumentoCliente,FechaDeCreacion_Notificacion,FechaDeInactivacion_Notificacion")] notificacion notificacion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(notificacion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ID_DocumentoAprendiz = new SelectList(db.aprendiz, "ID_DocumentoAprendiz", "Nombre_Aprendiz", notificacion.ID_DocumentoAprendiz);
     ViewBag.ID_DocumentoCliente  = new SelectList(db.cliente, "ID_DocumentoCliente", "PrimerNombre_Cliente", notificacion.ID_DocumentoCliente);
     ViewBag.ID_formato           = new SelectList(db.Formato_Ftp, "ID_formato", "Nombre_Formato", notificacion.ID_formato);
     return(View(notificacion));
 }
Example #10
0
        // GET: notificacion/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            notificacion notificacion = db.notificacion.Find(id);

            if (notificacion == null)
            {
                return(HttpNotFound());
            }
            return(View(notificacion));
        }
Example #11
0
        public async Task AgregarProducto(ProductoPresentacion prod, int cantidad, int listaId)
        {
            int cantidadAnterior = 0;

            if (pedido.ListaPreciosId != 0 && pedido.ListaPreciosId != listaId && pedido.detallePedido.Count > 0)
            {
                toastService.ShowWarning("No puede agregar productos de listas distintas. Para cambiar de lista tienes que vaciar el carrito primero");
            }
            else
            {
                pedido.ListaPreciosId = listaId;
                pedido.ListaPrecios   = listaVigente;
                await js.SetInLocalStorage("lista", Convert.ToString(listaId));

                if (pedido.detallePedido.Where(x => x.ProductoPresentacion.Id == prod.Id).Count() > 0)
                {
                    cantidadAnterior = pedido.detallePedido.FirstOrDefault(x => x.ProductoPresentacion.Id == prod.Id).cantidad;

                    pedido.detallePedido.FirstOrDefault(x => x.ProductoPresentacion.Id == prod.Id).cantidad = cantidad;
                }
                else
                {
                    decimal precio = listaVigente.DetalleListaPrecios.Single(x => x.ProductoPresentacionId == prod.Id).precioUnitarioFinal;

                    pedido.detallePedido.Add(new DetallePedido {
                        ProductoPresentacionId = prod.Id, ProductoPresentacion = prod, cantidad = cantidad, precioUnitario = precio
                    });
                }


                CalcularTotal();
                notificacion notificacion = new notificacion
                {
                    productoPresentacion = prod,
                    entra    = cantidad > cantidadAnterior ? true : false,
                    sale     = cantidad < cantidadAnterior ? true : false,
                    cantidad = Math.Abs(cantidadAnterior - cantidad)
                };


                notificaciones.Add(notificacion);
                LimpiarNotifiacion(notificacion);
                await carritoInLocalStore();

                //await mostrarNotificacion();
            }
        }
Example #12
0
        // GET: notificacion/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            notificacion notificacion = db.notificacion.Find(id);

            if (notificacion == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ID_DocumentoAprendiz = new SelectList(db.aprendiz, "ID_DocumentoAprendiz", "Nombre_Aprendiz", notificacion.ID_DocumentoAprendiz);
            ViewBag.ID_DocumentoCliente  = new SelectList(db.cliente, "ID_DocumentoCliente", "PrimerNombre_Cliente", notificacion.ID_DocumentoCliente);
            ViewBag.ID_formato           = new SelectList(db.Formato_Ftp, "ID_formato", "Nombre_Formato", notificacion.ID_formato);
            return(View(notificacion));
        }
        public notificacion[] data()
        {
            DataTable dt = obj_notificacion.get_notificacion();
            DataRow   row;

            notificacion[] notificacions = null;
            if (dt.Rows.Count > 0)
            {
                notificacions = new notificacion[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    row = dt.Rows[i];
                    notificacions[i] = new notificacion(Convert.ToInt64(row["notf_idnotificacion"].ToString()), row["notf_fecha"].ToString(), row["notf_recibida"].ToString(), Convert.ToInt64(row["user_emisor"].ToString()), Convert.ToInt64(row["user_destinatario"].ToString()), Convert.ToInt32(row["tntf_idtiponotif"].ToString()));
                }
            }
            return(notificacions);
        }
Example #14
0
        /// <summary>
        /// Notifica a todos los usuarios con privilegio específico.
        /// </summary>
        /// <param name="PRIVS_LLAVE"></param>
        /// <param name="estado"></param>
        /// <param name="titulo"></param>
        /// <param name="mensaje"></param>
        /// <param name="mensajeParams"></param>
        public void NotifyUsers(string PRIVS_LLAVE, EstadosNotificacion estado, string titulo, string mensaje, params object[] mensajeParams)
        {
            try
            {
                List <usuario> usuarios = null;

                if (string.IsNullOrEmpty(PRIVS_LLAVE))
                {
                    Seguridad.UsuarioLogic usuariologic = new Seguridad.UsuarioLogic();
                    usuarios = usuariologic.GetUsuarios();
                }
                else
                {
                    Seguridad.PrivilegioLogic privilegiologic = new Seguridad.PrivilegioLogic();
                    usuarios = privilegiologic.GetUsuariosWithPrivilege(PRIVS_LLAVE);
                }

                StringBuilder mensajeBuilder    = new StringBuilder();
                string        mensajeFormateado = mensajeBuilder.AppendFormat(mensaje, mensajeParams).ToString();

                using (var db = new colinasEntities())
                {
                    foreach (usuario usr in usuarios)
                    {
                        notificacion notification = new notificacion();
                        notification.NOTIFICACION_ESTADO  = (int)estado;
                        notification.USR_USERNAME         = usr.USR_USERNAME;
                        notification.NOTIFICACION_TITLE   = titulo;            //"Notas de Peso en Catación";
                        notification.NOTIFICACION_MENSAJE = mensajeFormateado; //"Ya tiene disponible la nota de peso #" + note.NOTAS_ID + ".";
                        notification.NOTIFICACION_FECHA   = DateTime.Now;

                        db.notificaciones.AddObject(notification);
                    }

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al notificar usuarios.", ex);
                throw;
            }
        }
Example #15
0
        public async Task removeFromProducCard(ProductoPresentacion producto)
        {
            int cantidad = pedido.detallePedido.Single(x => x.ProductoPresentacionId == producto.Id).cantidad;

            pedido.detallePedido.Remove(pedido.detallePedido.Single(x => x.ProductoPresentacionId == producto.Id));
            await carritoInLocalStore();

            CalcularTotal();

            notificacion notificacion = new notificacion
            {
                productoPresentacion = producto,
                entra    = false,
                sale     = true,
                cantidad = Math.Abs(cantidad)
            };


            notificaciones.Add(notificacion);
            LimpiarNotifiacion(notificacion);
        }