コード例 #1
0
 public static List <Address> ListAll()
 {
     using (var context = new ApplicationDBContent())
     {
         return(context.Addresses.ToList());
     }
 }
コード例 #2
0
 static void Main(string[] args)
 {
     using (var bd = new ApplicationDBContent())
     {
         bd.Database.Migrate();
     };
 }
コード例 #3
0
 public static User getQuery(string email, string password)
 {
     using (var context = new ApplicationDBContent())
     {
         return(null);
     }
 }
コード例 #4
0
 public static List <User> ListAll()
 {
     using (var context = new ApplicationDBContent())
     {
         return(context.Users.ToList());
     }
 }
コード例 #5
0
ファイル: CategoryViewModel.cs プロジェクト: Riquinho93/Servo
 public static void delete(Category category)
 {
     using (var context = new ApplicationDBContent())
     {
         context.Remove(category);
         context.SaveChanges();
     }
 }
コード例 #6
0
ファイル: ProductViewModel.cs プロジェクト: Riquinho93/Servo
 public static List <Product> ListAll()
 {
     using (var context = new ApplicationDBContent())
     {
         return(context.Products.Include(p => p.Category).AsNoTracking().Include(p => p.User).AsNoTracking().ToList());
         //return context.Products.Include(c => c.Category).ToList();
     }
 }
コード例 #7
0
 public static void delete(Address address)
 {
     using (var context = new ApplicationDBContent())
     {
         context.Remove(address);
         context.SaveChanges();
     }
 }
コード例 #8
0
ファイル: ProductViewModel.cs プロジェクト: Riquinho93/Servo
 public static Product getByIdUser(int id)
 {
     using (var context = new ApplicationDBContent())
     {
         return((from p in context.Products join c in context.Users on p.User.id equals id into c
                 select p).FirstOrDefault());
     }
 }
コード例 #9
0
 public static void delete(User user)
 {
     using (var context = new ApplicationDBContent())
     {
         context.Remove(user);
         context.SaveChanges();
     }
 }
コード例 #10
0
ファイル: ProductViewModel.cs プロジェクト: Riquinho93/Servo
 public static Product getById(int id)
 {
     using (var context = new ApplicationDBContent())
     {
         return((from p in context.Products join a in context.Addresses on p.Address.ProductId equals id into a
                 where p.Id.Equals(id)
                 select p).FirstOrDefault());
     }
 }
コード例 #11
0
 public static Address getByIdUser(int id)
 {
     using (var context = new ApplicationDBContent())
     {
         return((from p in context.Addresses
                 join c in context.Products on p.Product.Id equals id into c
                 select p).First());
     }
 }
コード例 #12
0
 public static User getById(int id)
 {
     using (var context = new ApplicationDBContent())
     {
         return((from p in context.Users
                 where p.id.Equals(id)
                 select p).FirstOrDefault());
     }
 }
コード例 #13
0
ファイル: CategoryViewModel.cs プロジェクト: Riquinho93/Servo
 public static Category getById(int id)
 {
     using (var context = new ApplicationDBContent())
     {
         return(context.Categories.Where(c => c.Id == id).Include(p => p.Products).FirstOrDefault());
         //return (from p in context.Categories
         //        where p.Id.Equals(id)
         //        select p).FirstOrDefault();
     }
 }
コード例 #14
0
ファイル: ProductViewModel.cs プロジェクト: Riquinho93/Servo
 public static void delete(Product product)
 {
     using (var context = new ApplicationDBContent())
     {
         Category category = CategoryViewModel.getById(product.Category.Id);
         Address  address  = AddressViewModel.getById(product.Address.Id);
         context.Remove(category);
         context.Remove(address);
         context.Remove(product);
         context.SaveChanges();
     }
 }
コード例 #15
0
ファイル: CategoryViewModel.cs プロジェクト: Riquinho93/Servo
        public static void createCategory(Category category)
        {
            using (var context = new ApplicationDBContent())
            {
                if (category.Id > 0)
                {
                    context.Attach(category);
                    context.Update(category);
                }
                else
                {
                    context.Categories.Add(category);
                }

                context.SaveChanges();
            }
        }
コード例 #16
0
        public static void createUser(User user)
        {
            using (var context = new ApplicationDBContent())
            {
                if (user.id > 0)
                {
                    context.Attach(user);
                    context.Update(user);
                }
                else
                {
                    context.Users.Add(user);
                }

                context.SaveChanges();
            }
        }
コード例 #17
0
        public void createAddress(Product product, Address address)
        {
            using (var context = new ApplicationDBContent())
            {
                if (address.Id > 0)
                {
                    context.Attach(address);
                    context.Update(address);
                }
                else
                {
                    context.Attach(address.Product);
                    context.Addresses.Add(address);
                }

                context.SaveChanges();
            }
        }
コード例 #18
0
ファイル: ProductViewModel.cs プロジェクト: Riquinho93/Servo
        public static void createProduct(Category category, Product product, User user)
        {
            using (var context = new ApplicationDBContent())
            {
                if (product.Id > 0)
                {
                    context.Attach(product);
                    context.Update(product);
                }
                else
                {
                    // context.Products.Add(product);
                    context.Attach(product.Category);
                    context.Attach(product.User);

                    category.Products.Add(product);
                }

                context.SaveChanges();
            }
        }
コード例 #19
0
        public static void createTelephone(Telephone telephone, Product prod)
        {
            using (var context = new ApplicationDBContent())
            {
                if (telephone.id > 0)
                {
                    context.Attach(telephone);
                    context.Update(telephone);
                }
                else
                {
                    // context.Products.Add(product);

                    context.Attach(telephone.products);

                    //  prod.Telephones.Add(telephone);
                }

                context.SaveChanges();
            }
        }
コード例 #20
0
ファイル: App.xaml.cs プロジェクト: Riquinho93/Servo
        /// <summary>
        /// Chamado quando o aplicativo é iniciado normalmente pelo usuário final.  Outros pontos de entrada
        /// serão usados, por exemplo, quando o aplicativo for iniciado para abrir um arquivo específico.
        /// </summary>
        /// <param name="e">Detalhes sobre a solicitação e o processo de inicialização.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Não repita a inicialização do aplicativo quando a Janela já tiver conteúdo,
            // apenas verifique se a janela está ativa
            if (rootFrame == null)
            {
                // Crie um Quadro para atuar como o contexto de navegação e navegue para a primeira página
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Carregue o estado do aplicativo suspenso anteriormente
                }

                using (var bd = new ApplicationDBContent())
                {
                    bd.Database.Migrate();
                };

                // Coloque o quadro na Janela atual
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // Quando a pilha de navegação não for restaurada, navegar para a primeira página,
                    // configurando a nova página passando as informações necessárias como um parâmetro
                    // parâmetro
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Verifique se a janela atual está ativa
                Window.Current.Activate();
            }
        }
コード例 #21
0
        private async void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new ApplicationDBContent())
            {
                User user = context.Users.FirstOrDefault(p => p.email == txtEmail.Text && p.password == txtPassword.Password);

                if (user != null)
                {
                    this.Frame.Navigate(typeof(Menu), user);
                }
                else
                {
                    Windows.UI.Popups.MessageDialog m = new Windows.UI.Popups.MessageDialog("Email or password is Incorrect!! ", "Login Error!");

                    m.ShowAsync();
                }
            }


            {
            }
        }
コード例 #22
0
ファイル: CategoryViewModel.cs プロジェクト: Riquinho93/Servo
 public static List <Category> ListAll()
 {
     using (var context = new ApplicationDBContent())
     {
         /*     List<Category> lista  = new List<Category>();
          *   Category cat = new Category();
          *   Category cat2 = new Category();
          *   Category cat3 = new Category();
          *
          *   cat.Id = 1;
          *   cat.Name = "Domésticos";
          *
          *   cat2.Id = 2;
          *   cat2.Name = "Eventos";
          *
          *   cat3.Id = 3;
          *   cat3.Name = "Reparações e Mudanças";
          *   lista.Add(cat);
          *   lista.Add(cat2);
          *   lista.Add(cat3);
          *   return lista; */
         return(context.Categories.ToList());
     }
 }