public static List <Address> ListAll() { using (var context = new ApplicationDBContent()) { return(context.Addresses.ToList()); } }
static void Main(string[] args) { using (var bd = new ApplicationDBContent()) { bd.Database.Migrate(); }; }
public static User getQuery(string email, string password) { using (var context = new ApplicationDBContent()) { return(null); } }
public static List <User> ListAll() { using (var context = new ApplicationDBContent()) { return(context.Users.ToList()); } }
public static void delete(Category category) { using (var context = new ApplicationDBContent()) { context.Remove(category); context.SaveChanges(); } }
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(); } }
public static void delete(Address address) { using (var context = new ApplicationDBContent()) { context.Remove(address); context.SaveChanges(); } }
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()); } }
public static void delete(User user) { using (var context = new ApplicationDBContent()) { context.Remove(user); context.SaveChanges(); } }
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()); } }
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()); } }
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()); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
/// <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(); } }
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(); } } { } }
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()); } }