public int Registration(string FirstName, string LastName, string Login, string Password, string Email, string Address) { using (FoodContext db = new FoodContext()) { bool log = false; bool em = false; Random rnd = new Random(); number = rnd.Next(1000, 9999); try { db.Users.First(x => (x.Login == Login)); } catch (Exception) { log = true; } if (log == false) { return(1); } try { db.Users.First(x => x.Email == Email); } catch (Exception) { em = true; } if (em == false) { return(2); } user = new User { FirstName = FirstName, LastName = LastName, Login = Login, Password = Password, Email = Email, Address = Address }; SendMail("Код подтверждения регистрации: " + number, Email); return(number); } }
public UserControl1() { InitializeComponent(); db = new FoodContext(); db.Categories.Load(); phonesGrid.ItemsSource = db.Categories.Local.ToBindingList(); }
public void Search(string DishName) { using (FoodContext db = new FoodContext()) { db.Dishes.Where(x => x.Category.Name == DishName).Load(); dishesGrid.ItemsSource = db.Dishes.Local.ToBindingList(); } }
public bool FinalRegistration(int number) { if (this.number == number) { using (FoodContext db = new FoodContext()) { db.Users.Add(user); db.SaveChanges(); return(true); } } else { return(false); } }
public IPerson Auth(string login, string password) { using (FoodContext db = new FoodContext()) { IPerson person; try { person = db.Users.First(x => (x.Login == login || x.Email == login && x.Password == password)); } catch (Exception) { person = null; }; if (person == null) { try { person = db.Admins.First(x => (x.Login == login && x.Password == password)); } catch (Exception) { person = null; } } return(person); } }
private void dishesGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { Dish dish = (Dish)dishesGrid.SelectedItem; dishimage.Source = new BitmapImage(new Uri("Images/" + dish.Photo + ".png", UriKind.Relative)); using (FoodContext db = new FoodContext()) { var ids = db.DishIngredients.Where(x => x.DishId == dish.Id).Select(x => x.IngredientId).ToArray(); db.Ingredients.Where(x => ids.Contains(x.Id)).Load(); ingredientsGrid.ItemsSource = db.Ingredients.Local.ToBindingList(); } dishname.Text = dish.Name; } catch (Exception) { } }
public MenuControl() { InitializeComponent(); db = new FoodContext(); }