示例#1
0
        public async void AddNova_Categoria(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNome.Text) == true)
            {
                await DisplayAlert("Atenção!", "Valor inválido", "Cancelar");

                return;
            }

            if (Categorias.Exists(X => X.Nome == txtNome.Text))
            {
                await DisplayAlert("Atenção!", "Já existe uma categoria com este nome registrado: " + txtNome.Text, "Cancelar");

                return;
            }

            int       idCategoria = Categorias.Count() == 0 ? 1 : (int)(Categorias.Max(x => x.CategoriaId) + 1);
            Categoria categoria   = new Categoria
            {
                CategoriaId = idCategoria,
                Nome        = txtNome.Text,
            };

            Categorias.Insert(categoria);
            await Navigation.PopAsync();
        }
示例#2
0
        public async void AddNova_Noticia(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTitulo.Text) == true)
            {
                await DisplayAlert("Atenção!", "Valor inválido", "Cancelar");

                return;
            }

            if (Noticias.Exists(X => X.Titulo == txtTitulo.Text))
            {
                await DisplayAlert("Atenção!", "Já existe uma notícia com este título registrado: " + txtTitulo.Text, "Cancelar");

                return;
            }

            int     idNoticia = Noticias.Count() == 0 ? 1 : (int)(Noticias.Max(x => x.NoticiaId) + 1);
            Noticia noticia   = new Noticia
            {
                NoticiaId = idNoticia,
                categoria = categoriaSelect,
                Titulo    = txtTitulo.Text,
                Descricao = edtDescricao.Text,
                DtNoticia = lblDtNoticia.Text,
            };

            Noticias.Insert(noticia);
            await Navigation.PopAsync();
        }
示例#3
0
        public Block FindLatestBlock()
        {
            var min = _blocks.Max("Height");

            if (min.AsInt64 > 0)
            {
                return(_blocks.FindOne(Query.EQ("Height", min.AsInt64)));
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        private void Insert(object sender, System.EventArgs e)
        {
            int idCustomer = Customers.Count() == 0 ? 1 : (int)(Customers.Max(x => x.Id) + 1);

            Customer customer = new Customer
            {
                Id   = idCustomer,
                Name = EntryName.Text,
            };

            Customers.Insert(customer);

            ListCustomers.ItemsSource = Customers.FindAll();
        }
        private void MinMaxCommon(LiteCollection <DateTimeTest> coll)
        {
            var searchdatetime = new DateTime(2018, 02, 22, 0, 0, 10);

            var min = coll.Min(x => x.Date).AsDateTime;
            var max = coll.Max(x => x.Date).AsDateTime;

            var smaller = coll.FindOne(x => x.Date < searchdatetime);
            var greater = coll.FindOne(x => x.Date > searchdatetime);

            var all = coll.FindAll().ToList();

            var linqmin = all.Min(x => x.Date);
            var linqmax = all.Max(x => x.Date);

            Assert.AreEqual(min, linqmin);
            Assert.AreEqual(max, linqmax);
        }
示例#6
0
        public Block FindLatestBlock()
        {
            //var count = GetBlockCount();
            //var result = FindBlockByIndex(count);
            int max = 0;

            var m = _blocks.Max(x => x.Index);

            if (m != null)
            {
                max = m.AsInt32;
            }

            if (max > 0)
            {
                return((Block)_blocks.FindOne(Query.EQ("Index", max)));
            }
            return(null);
        }
 /// <summary>
 /// Maximum by property.
 /// </summary>
 /// <param name="expression">Expression for specify mixumum field.</param>
 /// <returns>Maximum value.</returns>
 public BsonValue Max(Expression <Func <T, BsonValue> > expression)
 {
     return(m_Collection.Max(expression));
 }
 public BsonValue Max()
 {
     return(_collection.Max());
 }
示例#9
0
 public void InsertUsuario(Usuario usuario)
 {
     usuario.IdUsuario = Usuarios.Count() == 0 ? 1 : (int)(Usuarios.Max(x => x.IdUsuario) + 1);
     Usuarios.Insert(usuario);
 }
        /// <summary>
        ///     Gets all subscriptions from the database
        /// </summary>
        /// <returns></returns>
        public Block GetLastBlock()
        {
            var lastHeight = _blocks.Max(x => x.Height);

            return(lastHeight.AsInt64 == 0 ? null : _blocks.FindOne(x => x.Height == lastHeight));
        }
示例#11
0
 public BsonValue Max()
 {
     return(LiteCollection.Max());
 }