Ejemplo n.º 1
0
        public HttpResponseMessage ListarAgenda([FromBody]JObject model)
        {
            try
            {
                dynamic json = model["Funcionario"];
                int idFuncionario = 0;
                int ano = json.ano, mes = json.mes, dia = json.dia;
                //DateTime data = new DateTime(ano, mes+1, dia);
                idFuncionario = json.idEmpresaCliente;
                List<Agenda> agendaProfissional = new List<Agenda>();
                DBContext db = new DBContext();

                var query = from a in db.Agenda
                            where a.idEmpresaCliente == idFuncionario
                            && a.horarioAgenda.Year == ano
                            && a.horarioAgenda.Month == mes + 1
                            && a.horarioAgenda.Day == dia
                            select a;
                foreach (Agenda a in query)
                {
                    agendaProfissional.Add(a);
                }

                return Request.CreateResponse(HttpStatusCode.OK, agendaProfissional);

            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage CadastroCategoria(Categoria c)
        {
            try
            {
                using (DBContext db = new DBContext())
                {
                    db.Database.CreateIfNotExists();
                    db.Categoria.Add(c);
                    db.SaveChanges();
                }
                return Request.CreateResponse(HttpStatusCode.OK, "Cadastro da categoria " + c.nomeCategoria + " realizado.");
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);

            }
        }
Ejemplo n.º 3
0
        public HttpResponseMessage ListarCategorias([FromBody]JObject model)
        {
            try
            {
                List<Categoria> categorias = new List<Categoria>();
                using(DBContext db = new DBContext())
                {
                    db.Database.CreateIfNotExists();
                    var query = from c in db.Categoria select c;

                    foreach (Categoria cat in query)
                    {
                        categorias.Add(cat);
                    }
                }
                return Request.CreateResponse(HttpStatusCode.OK, categorias);
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
            }
        }
Ejemplo n.º 4
0
        public static Usuario VerificarUsuario(string password, int user)
        {
            try
            {
                var usuario = new Usuario();

                using (DBContext db = new DBContext())
                {
                    var pass = Decrypt(password);
                    var query = from u in db.Usuario
                                where u.idUsuario == user && u.senhaUsuario == pass
                                select u;
                    foreach (Usuario u in query)
                    {
                        usuario = u;
                    }
                }
                return usuario;
            }catch(Exception)
            {
                return null;
            }
        }
        public HttpResponseMessage CadastroEmpresa([FromBody]JObject model)
        {
            try
            {
                dynamic json = model["Horario"];
                var idUsuario = 0;
                var idCliente = 0;
                string dataServico = json.dataServico;
                idUsuario = json.idUsuario;

                DBContext db = new DBContext();
                var query = from user in db.Usuario
                            where user.idUsuario == idUsuario
                            select user.idCliente;
                foreach (var x in query)
                {
                    idCliente = x;
                }
                ClienteServico cs = new ClienteServico()
                {
                    dataServico = Convert.ToDateTime(json.dataServico),
                    idEmpresaClienteServico = json.idEmpresaCliente,
                    valorServico = json.valorServico,
                    idCliente = idCliente
                };
                db.Database.CreateIfNotExists();
                db.ClienteServico.Add(cs);
                db.SaveChanges();

                return Request.CreateResponse(HttpStatusCode.OK, "Cadastro realizado.");
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);

            }
        }