예제 #1
0
        public async Task <bool> CheckPeople(int idUser, ColaViewModel llamada)
        {
            bool state = false;

            try
            {
                var Agendar = new agenda();
                Agendar.idusuario  = idUser;
                Agendar.idpersona  = llamada.idPersona;
                Agendar.idproducto = 1;
                Agendar.fecha      = DateTime.Now.Date;
                Agendar.hora       = DateTime.Now.Date.TimeOfDay;
                Agendar.idstate    = 1;
                Agendar.comentario = "Para Verificar";

                db.Add(Agendar);
                await db.SaveChangesAsync();

                state = true;
            }
            catch (Exception ex)
            {
                state = false;
            }
            return(state);
        }
예제 #2
0
        public async Task <ReplyViewModel> AgregarSeg(int idUser, SeguimientoViewModel seguimiento)
        {
            try
            {
                if (!TieneSeg(int.Parse(seguimiento.idPersona.ToString())))
                {
                    DateTime hora = DateTime.Parse(seguimiento.Hora);
                    var      Seg  = new seguimientos();
                    Seg.idusuario  = idUser;
                    Seg.idpersona  = seguimiento.idPersona;
                    Seg.idproducto = 1;
                    Seg.fecha      = DateTime.Parse(seguimiento.Fecha);
                    Seg.hora       = TimeSpan.Parse(hora.ToString("HH:mm"));
                    Seg.comentario = seguimiento.Comentario;
                    Seg.fechaseg   = DateTime.Now.Date;
                    Seg.idstate    = 1;


                    db.Add(Seg);
                    await db.SaveChangesAsync();

                    reply.result = 1; reply.message = "Se Agrego el Seguimiento";
                }
                else
                {
                    reply.result = 0; reply.message = "Ya Hay Un Seguimiento para esta Persona";
                }
            }
            catch (Exception ex)
            {
                reply.result = 0; reply.message = "Ocurrio Un error";
            }
            return(reply);
        }
예제 #3
0
        public async Task <bool> AddOP(int idUser, OpViewModel operacion)
        {
            bool state = false;

            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    var oPersona = db.personas.Where(x => x.idpersona == operacion.idPersona).FirstOrDefault();
                    oPersona.localidad       = operacion.localidad;
                    oPersona.calle           = operacion.calle;
                    oPersona.altura          = operacion.altura.ToString();
                    oPersona.piso            = operacion.piso.ToString();
                    oPersona.dpto            = operacion.dpto;
                    db.Entry(oPersona).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    db.SaveChanges();

                    var      Op   = new cerrados();
                    DateTime hora = DateTime.Parse(operacion.hora);
                    Op.idpersona   = operacion.idPersona;
                    Op.idproducto  = 1;
                    Op.idusuario   = idUser;
                    Op.idstate     = 1;
                    Op.idargumento = 3;
                    Op.fechacierre = DateTime.Now.Date;
                    Op.fecha       = DateTime.Parse(operacion.fecha);
                    Op.hora        = TimeSpan.Parse(hora.ToString("HH:mm"));
                    Op.comentario  = operacion.comentario;

                    db.Add(Op);
                    db.SaveChanges();

                    await transaction.CommitAsync();

                    state = true;
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    state = false;
                }
            }

            return(state);
        }
예제 #4
0
파일: Call.cs 프로젝트: pminkevich/Repos
        public async Task <bool> GoToCall <T>(int idUser, T model)
        {
            bool state = false;
            //uso reflexion
            PropertyInfo personaid  = model.GetType().GetProperty("idPersona");
            PropertyInfo productoid = model.GetType().GetProperty("idProducto");

            int idPersona  = int.Parse(personaid.GetValue(model).ToString());
            int idProducto = int.Parse(productoid.GetValue(model).ToString());


            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    DateTime hoy      = DateTime.Now.Date;
                    var      enCola   = db.llamados.Where(x => x.fecha == hoy && x.idusuario == idUser && x.idpersona == idPersona);
                    var      llamando = db.llamados.Where(x => x.fecha == hoy && x.idusuario == idUser && x.callstate.valor == "llamando");


                    if (llamando.Count() > 0)
                    {
                        //paso el estado a  en cola

                        var llamandoahora = llamando.FirstOrDefault();
                        llamandoahora.idstate         = 1;
                        db.Entry(llamandoahora).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                        db.SaveChanges();
                    }

                    if (enCola.Count() > 0)
                    {
                        //cambio el estado a llamando
                        var llamadoencola = enCola.FirstOrDefault();
                        llamadoencola.idstate         = 2;
                        db.Entry(llamadoencola).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                        //agrego el seguimiento a la cola de hoy
                        var newcall = new llamados();
                        newcall.idusuario   = idUser;
                        newcall.idpersona   = idPersona;  //seguimiento.idPersona;
                        newcall.idproducto  = idProducto; //seguimiento.idProducto;
                        newcall.idargumento = 3;
                        newcall.idstate     = 2;
                        newcall.fecha       = DateTime.Now;
                        newcall.hora        = DateTime.Now.TimeOfDay;
                        db.Add(newcall);
                        db.SaveChanges();
                    }

                    await transaction.CommitAsync();

                    state = true;
                }
                catch (Exception ex)
                {
                }
            }

            return(state);
        }