Exemplo n.º 1
0
        public async Task <ReplyViewModel> AddOp([FromHeader] string auth, OpViewModel operacion)
        {
            try
            {
                int User = _service.CheckToken(auth);
                if (User > 0)
                {
                    if (await _service.AddOP(User, operacion))
                    {
                        reply.result = 1; reply.message = "Se Inicio la Operación";
                    }
                    else
                    {
                        reply.result = 0; reply.message = "No se Pudo Iniciar la Operación";
                    }
                }
                else
                {
                    reply.result = 0; reply.message = "Acceso no Permitido";
                }
            }
            catch (Exception ex)
            {
                reply.result = 0; reply.message = "Ocurrio un Error";
            }

            return(reply);
        }
        public ActionResult <CorporateViewModel> Post(OpViewModel op)
        {
            CorporateViewModel model = this._corporateService.Get(op.A, op.B);


            return(Ok(model));
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        public async Task <ReplyViewModel> GoToCall([FromHeader] string auth, OpViewModel operacion)
        {
            int IdUser = _service.CheckToken(auth);

            if (IdUser > 0)
            {
                if (await _service.GoToCall(IdUser, operacion))
                {
                    reply.result = 1; reply.message = "Listo para llamar";
                }
                else
                {
                    reply.result = 0; reply.message = "No se pudo Agregar a la Cola";
                }
            }
            else
            {
                reply.result  = 3;
                reply.message = "Acceso no Permitido";
            }

            return(reply);
        }