private void butonGetir() { int i = 0; using (var cafeContect = new CafeContext()) { var result = from categories in cafeContect.Categories select categories; foreach (var gez in result) { Button kategori = new Button(); kategori.Name = gez.CategoryID.ToString(); kategori.Text = gez.CategoryName; kategori.Font = new System.Drawing.Font(gez.CategoryName, 8, FontStyle.Bold); kategori.ForeColor = Color.DimGray; kategori.BackColor = Color.Transparent; if (i < 6) { kategori.Size = new Size(150, 35); flowLayoutPanel2.Controls.Add(kategori); } else { kategori.Size = new Size(100, 35); flowLayoutPanel3.Controls.Add(kategori); } i++; kategori.Click += new EventHandler(kategoriTiklama); } } }
private void tbsearch_TextChanged(object sender, EventArgs e) { using (var cafeContext1 = new CafeContext()) { listView1.Items.Clear(); listView1.View = View.Details; listView1.FullRowSelect = true; listView1.GridLines = true; using (var cafeContext = new CafeContext()) { var result2 = from products in cafeContext.Products join categories in cafeContext.Categories on products.Category.CategoryID equals categories.CategoryID where products.ProductName.Contains(tbsearch.Text) select new { products, categories }; foreach (var product in result2) { ListViewItem ekle = new ListViewItem(); ekle.Text = product.products.ProductID.ToString(); ekle.SubItems.Add(product.products.ProductName.ToString()); ekle.SubItems.Add(product.categories.CategoryName.ToString()); ekle.SubItems.Add(product.products.Amount.ToString()); listView1.Items.Add(ekle); } } } }
private void btnOdeme_Click(object sender, EventArgs e) { using (var cafeContext = new CafeContext()) { int tableNumber = int.Parse(MainForm.Masa); var result = from receipt in cafeContext.Receipts join orders in cafeContext.Orders on receipt.TableNumber equals orders.TableNumber where receipt.TableNumber == tableNumber && orders.isAlive == true select new { orders, receipt }; foreach (var gez in result) { receiptID = gez.receipt.ReceiptID; Order order = cafeContext.Orders.Find(gez.orders.OrderID); order.isAlive = false; } cafeContext.SaveChanges(); kosullama(Color.Gray); LoadingForm.kuver = ""; odeme = true; this.Close(); pdf gcs = new pdf(); gcs.ShowDialog(); } }
public void verigoster() { listView1.Items.Clear(); cbtur.Items.Clear(); listView1.View = View.Details; listView1.FullRowSelect = true; listView1.GridLines = true; using (var cafeContext = new CafeContext()) { var result = from products in cafeContext.Products join categories in cafeContext.Categories on products.Category.CategoryID equals categories.CategoryID select new { products, categories }; foreach (var product in result) { ListViewItem ekle = new ListViewItem(); ekle.Text = product.products.ProductID.ToString(); ekle.SubItems.Add(product.products.ProductName.ToString()); ekle.SubItems.Add(product.categories.CategoryName.ToString()); ekle.SubItems.Add(product.products.Amount.ToString()); listView1.Items.Add(ekle); } var result1 = from categories in cafeContext.Categories select categories; foreach (var category in result1) { cbtur.Items.Add(category.CategoryName); } } }
private void siparisEkleme(int adet) { using (var cafeContext = new CafeContext()) { int id = 0; int tableNumber = int.Parse(MainForm.Masa); var result = from products in cafeContext.Products where products.ProductName == UrunAdi select products; var result1 = from receipts in cafeContext.Receipts where receipts.TableNumber == tableNumber select receipts; var resultPrice = from receipt1 in cafeContext.Receipts where receipt1.TableNumber == tableNumber select receipt1.ReceiptID; foreach (var gez in resultPrice) { id = gez; } cafeContext.Orders.Add(new Order { ProductCount = adet, isAlive = true, TableNumber = int.Parse(MainForm.Masa), Information = "DETAY YOK", Product = result.FirstOrDefault(), Receipt = result1.FirstOrDefault() }); Receipt receipt = cafeContext.Receipts.Find(id); receipt.TotalPrice = int.Parse(lblfiyat.Text); cafeContext.SaveChanges(); veriGoster(); islemler(); } }
private void urunOlustur(string tur) { string urunAdi = ""; int urunSayisi = 0, i = 0; flowLayoutPanel1.Controls.Clear(); using (var cc = new CafeContext()) { var result = from products in cc.Products where products.Category.CategoryName == tur select products; foreach (var gez in result) { urunAdi = gez.ProductName; Button urun = new Button(); urun.Name = urunAdi; urun.Text = urunAdi; urun.Font = new System.Drawing.Font(gez.ProductName, 8, FontStyle.Bold); urun.ForeColor = Color.DimGray; urun.Size = new Size(145, 35); urun.BackColor = Color.Transparent; Panel panel = new Panel(); panel.Name = i.ToString() + "panel"; panel.Size = new Size(7, 35); panel.BackColor = Color.Transparent; flowLayoutPanel1.Controls.Add(urun); flowLayoutPanel1.Controls.Add(panel); i++; urun.Click += new EventHandler(urunTiklama); } urunSayisi = result.Count(); } }
private void btnkaydet_Click(object sender, EventArgs e) { try { if (tbmasa.Text.Length != 0) { using (var cafeContext = new CafeContext()) { var result = from cafeId in cafeContext.Cafe where cafeId.CafeID == 1 select cafeId.CafeID; Cafe cafe = cafeContext.Cafe.Find(1); cafe.TableCount = int.Parse(tbmasa.Text); cafeContext.SaveChanges(); MessageBox.Show("Güncel masa miktarı için programı kapatıp yeniden açınız.", "Güncelleme Başarılı!", MessageBoxButtons.OK, MessageBoxIcon.Information); tbmasa.Clear(); } } else { MessageBox.Show("Boş alan bırakmayınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { } }
private void btnekle_Click(object sender, EventArgs e) { try { if (tbadi.Text.Length != 0 && tbsoyadi.Text.Length != 0 && comboBox1.Text.Length != 0 && tbtc.Text.Length != 0 && textBox1.Text.Length != 0) { using (var cafeContext = new CafeContext()) { var result = from personals in cafeContext.Personals select personals; cafeContext.Personals.Add(new Personal { PersonalName = tbadi.Text, PersonalSurname = tbsoyadi.Text, PersonelID = tbtc.Text, PersonalCell = textBox1.Text, PersonalRank = comboBox1.Text }); cafeContext.SaveChanges(); } verigoster(); } else { MessageBox.Show("Boş alan bırakmayınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show("Böyle bir kayıt vardır."); } }
private void btncafe_Click(object sender, EventArgs e) { try { if (tbcparola.Text.Length != 0 && tbcadi.Text.Length != 0) { using (var cafeContext = new CafeContext()) { var result = from cafes in cafeContext.Cafe where cafes.CafeID == 1 select cafes.CafeID; Cafe cafe = cafeContext.Cafe.Find(1); cafe.CafeEntry = tbcadi.Text; cafe.CafeLoginKey = tbcparola.Text; cafeContext.SaveChanges(); MessageBox.Show("Güncelleme Başarılı!"); tbcadi.Clear(); tbcparola.Clear(); } } else { MessageBox.Show("Boş alan bırakmayınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { } }
public static void StockUpForSandwich(CafeContext cafeContext, int serves) { Stock stock; stock = GetStock(cafeContext, "Bread"); if (stock != null) { cafeContext.StockItems.Add( new StockItem { Stock = stock, Quantity = serves * 2, Unit = "slices", TimeRequired = DateTime.Now }); } stock = GetStock(cafeContext, "Butter"); if (stock != null) { cafeContext.StockItems.Add( new StockItem { Stock = stock, Quantity = serves * 5, Unit = "g", TimeRequired = DateTime.Now }); } stock = GetStock(cafeContext, "Cheese"); if (stock != null) { cafeContext.StockItems.Add( new StockItem { Stock = stock, Quantity = serves * 100, Unit = "g", TimeRequired = DateTime.Now }); } }
private void tbsearch_TextChanged(object sender, EventArgs e) { using (var cafeContext1 = new CafeContext()) { listView1.Items.Clear(); listView1.View = View.Details; listView1.FullRowSelect = true; listView1.GridLines = true; using (var cafeContext = new CafeContext()) { var result2 = from personals in cafeContext.Personals where personals.PersonalName.Contains(tbsearch.Text) select personals; foreach (var personel in result2) { ListViewItem ekle = new ListViewItem(); ekle.Text = personel.PersonelID.ToString(); ekle.SubItems.Add(personel.PersonalName.ToString()); ekle.SubItems.Add(personel.PersonalSurname.ToString()); ekle.SubItems.Add(personel.PersonalCell.ToString()); ekle.SubItems.Add(personel.PersonalRank.ToString()); listView1.Items.Add(ekle); } } } }
public static void StockUpForHotBeverage(CafeContext cafeContext, int serves) { Stock stock; stock = GetStock(cafeContext, "Coffee"); if (stock != null) { cafeContext.StockItems.Add( new StockItem { Stock = stock, Quantity = serves * 10, Unit = "g", TimeRequired = DateTime.Now }); } stock = GetStock(cafeContext, "Sugar"); if (stock != null) { cafeContext.StockItems.Add( new StockItem { Stock = stock, Quantity = serves * 1, Unit = "g", TimeRequired = DateTime.Now }); } stock = GetStock(cafeContext, "Milk"); if (stock != null) { cafeContext.StockItems.Add( new StockItem { Stock = stock, Quantity = serves * 100, Unit = "ml", TimeRequired = DateTime.Now }); } }
public static void StockUpForSalad(CafeContext cafeContext, int serves) { Stock stock; stock = GetStock(cafeContext, "Lettuce"); if (stock != null) { cafeContext.StockItems.Add( new StockItem { Stock = stock, Quantity = serves * 50, Unit = "g", TimeRequired = DateTime.Now }); } stock = GetStock(cafeContext, "Dressing"); if (stock != null) { cafeContext.StockItems.Add( new StockItem { Stock = stock, Quantity = serves * 5, Unit = "ml", TimeRequired = DateTime.Now }); } stock = GetStock(cafeContext, "Tomato"); if (stock != null) { cafeContext.StockItems.Add( new StockItem { Stock = stock, Quantity = serves * 100, Unit = "g", TimeRequired = DateTime.Now }); } }
private void masaTiklama(object sender, EventArgs e) { Button btn = (Button)sender; Masa = btn.Name; using (var cafeContext = new CafeContext()) { int temp = int.Parse(Masa); var result = from receipts in cafeContext.Receipts join orders in cafeContext.Orders on receipts.ReceiptID equals orders.Receipt.ReceiptID where receipts.TableNumber == temp && orders.isAlive == true select receipts; if (result.Count() > 0) { TableForm gcs = new TableForm(); gcs.ShowDialog(); } else { LoadingForm gcs = new LoadingForm(); gcs.ShowDialog(); } } }
private void button1_Click(object sender, EventArgs e) { using (var cafeContext = new CafeContext()) { var result = from cafe in cafeContext.Cafe where cafe.CafeEntry == tbadi.Text && cafe.CafeLoginKey == tbparola.Text select cafe; if (tbadi.Text == "Admin" && tbparola.Text == "pass") { adminGiris = 1; this.Hide(); MainForm gcs = new MainForm(); gcs.ShowDialog(); } else if (result.Count() == 0) { MessageBox.Show("Böyle bir kullanıcı yoktur.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { adminGiris = 0; this.Hide(); MainForm gcs = new MainForm(); gcs.ShowDialog(); } } }
public void veriGoster() { int temp = int.Parse(MainForm.Masa); listView1.Items.Clear(); listView1.View = View.Details; listView1.FullRowSelect = true; listView1.GridLines = true; using (var cafeContext = new CafeContext()) { var result = from orders in cafeContext.Orders join products in cafeContext.Products on orders.Product.ProductID equals products.ProductID where orders.isAlive == true && orders.TableNumber == temp select new { orders, products }; foreach (var order in result) { ListViewItem ekle = new ListViewItem(); ekle.Text = order.orders.OrderID.ToString(); ekle.SubItems.Add(order.orders.ProductCount.ToString()); ekle.SubItems.Add(order.products.ProductName); ekle.SubItems.Add(order.products.Amount.ToString()); listView1.Items.Add(ekle); } } }
public MenuController(CafeContext cafeContext, ILogger <MenuController> logger) { _cafeContext = cafeContext; _logger = logger; _runtime = new Runtime(QueueMode.Server); _runtime.QueueSendType = "MenuItem"; }
public UserController(CafeContext cafeContext, ILogger <UserController> logger) { _cafeContext = cafeContext; _logger = logger; _runtime = new Runtime(QueueMode.Server); _runtime.QueueSendType = "OrderItem"; }
private void masaOlustur() { int masaSayisi = 20; using (var cafeContext = new CafeContext()) { var result = from cafes in cafeContext.Cafe where cafes.CafeID == 1 select cafes.TableCount; foreach (var gez in result) { masaSayisi = gez; } } for (i = 1; i <= masaSayisi; i++) { Button masa = new Button(); masa.Name = i.ToString(); masa.Text = i.ToString(); masa.Size = new Size(50, 50); using (var cafeContext = new CafeContext()) { var result = from receipts in cafeContext.Receipts join orders in cafeContext.Orders on receipts.TableNumber equals orders.TableNumber where receipts.TableNumber == i && orders.isAlive == true select receipts; if (result.Count() > 0) { foreach (var gez in result) { masa.BackColor = Color.DarkRed; } } else { masa.BackColor = Color.Gray; } } Panel panel = new Panel(); panel.Name = i.ToString() + "panel"; panel.Size = new Size(25, 50); panel.BackColor = Color.Transparent; flowLayoutPanel1.Controls.Add(masa); flowLayoutPanel1.Controls.Add(panel); if (i % 16 == 0) { panel.Size = new Size(1350, 19); flowLayoutPanel1.Controls.Add(panel); } masa.Click += new EventHandler(masaTiklama); } }
public static void AddStock(CafeContext cafeContext, string name) { if (cafeContext.Stocks.FirstOrDefault( stock => stock.Name == name) == null) { cafeContext.Stocks.Add(new Stock { Name = name }); } }
public PartialViewResult BaristaLogin(string returnUrl) { BaristaLoginModel model = new BaristaLoginModel(); using (CafeContext context = new CafeContext()) { model.LocationChoices = context.Locations.ToList().Select(loc => new SelectListItem { Text = loc.Name, Value = loc.LocationID.ToString() }); } ViewBag.ReturnUrl = returnUrl; return PartialView("_BaristaSignInPartial", model); }
public ActionResult Create(int id) { using (CafeContext context = new CafeContext()) { ViewBag.LocationName = context.Locations.FirstOrDefault(loc => loc.LocationID == id).Name; } OrderViewModel o = new OrderViewModel { LocationID = id }; return View(o); }
public FoodController(CafeContext context) { _context = context; if (_context.Foods.Count() == 0) { _context.Foods.Add(new Food { FoodId = Guid.NewGuid(), Name = "Sandwich" }); _context.SaveChanges(); } }
private void btnduzenle_Click(object sender, EventArgs e) { try { if (satir == -1) { MessageBox.Show("Düzenlemek için lütfen seçim yapınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (tbadi.Text.Length != 0 && tbfiyat.Text.Length != 0 && cbtur.Text.Length != 0) { using (var cafeContext = new CafeContext()) { var resultProduct = from products in cafeContext.Products where products.ProductName.ToLower() == tbadi.Text.ToLower() select products; if (resultProduct.Count() == 0 || urunAdi.ToLower() == tbadi.Text.ToLower()) { var result = from categoryId in cafeContext.Categories where categoryId.CategoryName == cbtur.Text select categoryId.CategoryID; int id = result.FirstOrDefault(); Product product = cafeContext.Products.Find(satir); Category category = cafeContext.Categories.Find(id); product.ProductID = satir; product.ProductName = tbadi.Text; product.Category = category; product.Amount = float.Parse(tbfiyat.Text); cafeContext.SaveChanges(); } else { MessageBox.Show("Böyle bir ürün mevcuttur. Lütfen ürün ismini değiştiriniz.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error); } } verigoster(); } else { MessageBox.Show("Boş alan bırakmayınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch { } }
public MainForm() { bool serverflag = false; do { SQLServerSelectionForm ConnectionStringForm = new SQLServerSelectionForm(); ConnectionStringForm.ShowDialog(); InitializeComponent(); db = new CafeContext(); try { MainGrid.DataSource = db.Orders.ToList(); serverflag = true; } catch (System.Data.SqlClient.SqlException e) { MessageBox.Show("Your server is invalid"); } }while (!serverflag); _currentTable = db.Orders.GetType(); HideBTN(); OrdStateBTN.Visible = true; OrdStateFiltBTN.Visible = true; this.ChangebleCompontents.Add(BTNHighestPriceMenu); this.ChangebleCompontents.Add(ChefBirthBTN); this.ChangebleCompontents.Add(ChefSalaryBTN); this.ChangebleCompontents.Add(MenCostBTN); this.ChangebleCompontents.Add(MenTimeBTN); this.ChangebleCompontents.Add(ProdTypeBTN); this.ChangebleCompontents.Add(ProdCountBTN); this.ChangebleCompontents.Add(OrdStateBTN); this.ChangebleCompontents.Add(OrdStateFiltBTN); this.ChangebleCompontents.Add(ChekFileBTN); this.ChangebleCompontents.Add(ChefPozFilterBTN); this.ChangebleCompontents.Add(ChefPozFilterTB); this.ChangebleCompontents.Add(MenuDishNameTB); this.ChangebleCompontents.Add(MenuDishNameBTN); this.ChangebleCompontents.Add(ChefSalBTN); this.ChangebleCompontents.Add(ProductSaveBTN); this.ChangebleCompontents.Add(ProductNameTB); this.ChangebleCompontents.Add(ProductNameBTN); this.ChangebleCompontents.Add(MenuCostFilterCB); this.ChangebleCompontents.Add(MenuCostFilterTB); this.ChangebleCompontents.Add(MenuCostFilterBTN); this.ChangebleCompontents.Add(ChefSalaryFilterCB); this.ChangebleCompontents.Add(ChefSalaryFilterTB); this.ChangebleCompontents.Add(ChefSalaryFilterBTN); }
public ActionResult Complete(int id) { using (CafeContext context = new CafeContext()) { Order toStart = context.Orders.Single(order => order.OrderID == id); TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); DateTime pacificTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tz); toStart.CompletedAt = pacificTime; context.SaveChanges(); ViewBag.UserName = context.UserProfiles.FirstOrDefault(user => user.UserId == toStart.UserID).UserName; return RedirectToAction("Process", "Order", new { id=toStart.LocationID}); } }
private void TableForm_FormClosing(object sender, FormClosingEventArgs e) { try { using (var cafeContext = new CafeContext()) { int tableNumber = int.Parse(MainForm.Masa); var result = from receipt in cafeContext.Receipts where receipt.TotalPrice == 0 && receipt.TableNumber == tableNumber select receipt; cafeContext.Receipts.Remove(result.First()); cafeContext.SaveChanges(); } } catch { } }
private void btnsil_Click(object sender, EventArgs e) { try { using (var cafeContext = new CafeContext()) { Product product = cafeContext.Products.Find(satir); cafeContext.Products.Remove(product); cafeContext.SaveChanges(); } verigoster(); } catch { MessageBox.Show("Silmek için lütfen seçim yapınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public ActionResult BaristaLogin(BaristaLoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { return RedirectToRoute("Location_default", new { controller = "Order", action = "Process", id = model.SelectedLocationID }); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); //this is here in case we fail login we repopulate to avoid error using (CafeContext context = new CafeContext()) { model.LocationChoices = context.Locations.ToList().Select(loc => new SelectListItem { Text = loc.Name, Value = loc.LocationID.ToString() }); } return PartialView("_BaristaSignInPartial", model); }
private void btnIptal_Click(object sender, EventArgs e) { try { using (var cafeContext = new CafeContext()) { Order order = cafeContext.Orders.Find(satir); cafeContext.Orders.Remove(order); cafeContext.SaveChanges(); } veriGoster(); islemler(); } catch { MessageBox.Show("Silmek için lütfen seçim yapınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnduzenle_Click(object sender, EventArgs e) { try { if (tc == "") { MessageBox.Show("Düzenlemek için lütfen seçim yapınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (tbadi.Text.Length != 0 && tbsoyadi.Text.Length != 0 && comboBox1.Text.Length != 0 && tbtc.Text.Length != 0 && textBox1.Text.Length != 0) { using (var cafeContext = new CafeContext()) { var result = from personals in cafeContext.Personals where personals.PersonelID.ToLower() == tbtc.Text.ToLower() select personals; if (result.Count() == 0 || tc == tbtc.Text) { Personal personal = cafeContext.Personals.Find(tc); personal.PersonalName = tbadi.Text; personal.PersonalSurname = tbsoyadi.Text; personal.PersonalCell = textBox1.Text; personal.PersonalRank = comboBox1.Text; personal.PersonelID = tc; cafeContext.SaveChanges(); } else { MessageBox.Show("Böyle bir personel mevcuttur. Lütfen personel ismini değiştiriniz.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error); } } verigoster(); } else { MessageBox.Show("Boş alan bırakmayınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch { } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); Database.SetInitializer(new CafeContextInitializer()); CafeContext context = new CafeContext(); context.Database.Initialize(true); WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); if (!Roles.RoleExists("Barista")) { Roles.CreateRole("Barista"); } }
private void btnMutfagaMesaj_Click(object sender, EventArgs e) { string IsimGirisi = Interaction.InputBox("Açıklamayı giriniz...", "SİPARİŞ DETAYI", "Örn: BUZLU OLSUN", 550, 300); try { using (var cafeContext = new CafeContext()) { var result = from orders in cafeContext.Orders where orders.OrderID == satir select orders.OrderID; int id = result.FirstOrDefault(); Order order = cafeContext.Orders.Find(id); order.Information = IsimGirisi; cafeContext.SaveChanges(); } veriGoster(); } catch { } }
private void btnekle_Click(object sender, EventArgs e) { try { if (tbadi.Text.Length != 0 && tbfiyat.Text.Length != 0 && cbtur.Text.Length != 0) { using (var cafeContext = new CafeContext()) { var resultProduct = from products in cafeContext.Products where products.ProductName.ToLower() == tbadi.Text.ToLower() select products; if (resultProduct.Count() == 0) { var result = from categories in cafeContext.Categories where categories.CategoryName == cbtur.Text select categories; cafeContext.Products.Add(new Product { ProductName = tbadi.Text, Amount = float.Parse(tbfiyat.Text), Category = result.FirstOrDefault() }); cafeContext.SaveChanges(); } else { MessageBox.Show("Böyle bir ürün mevcuttur. Lütfen ürün ismini değiştiriniz.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error); } } verigoster(); } else { MessageBox.Show("Boş alan bırakmayınız.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { } }
public ActionResult Create(OrderViewModel order) { using (CafeContext context = new CafeContext()) { if (ModelState.IsValid) { TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); DateTime pacificTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tz); if (order.PickUpAt.HasValue) { order.PickUpAt = TimeZoneInfo.ConvertTimeFromUtc(order.PickUpAt.Value.ToUniversalTime(), tz); } Order toAdd = new Order { LocationID = order.LocationID, PickUpAt = order.PickUpAt, CreatedAt = pacificTime, UserID = WebSecurity.GetUserId(User.Identity.Name) }; context.Orders.Add(toAdd); context.SaveChanges(); return RedirectToAction("Index"); } } return View(order); }
private void button2_Click(object sender, EventArgs e) { if (kuver != "") { using (var cafeContext = new CafeContext()) { int temp = int.Parse(MainForm.Masa); var result = from receipts in cafeContext.Receipts select receipts; cafeContext.Receipts.Add(new Receipt { Cover = int.Parse(kuver), Date = DateTime.Now.ToString(), TableNumber = temp }); cafeContext.SaveChanges(); } TableForm gcs = new TableForm(); gcs.ShowDialog(); this.Close(); } }
// // GET: /Location/Order/ public ActionResult Index() { IEnumerable<OrderViewModel> orders; using (CafeContext context = new CafeContext()) { int userID = WebSecurity.GetUserId(User.Identity.Name); orders = context.Orders.Where(o => o.UserID == userID).Select(ovm => new OrderViewModel() { CancelledAt = ovm.CancelledAt, CompletedAt = ovm.CompletedAt, CreatedAt = ovm.CreatedAt, LocationID = ovm.LocationID, OrderID = ovm.OrderID, PickUpAt = ovm.PickUpAt, StartedAt = ovm.StartedAt, UserID = ovm.UserID, UserName = context.UserProfiles.FirstOrDefault(user => user.UserId == ovm.UserID).UserName, LocationName = context.Locations.FirstOrDefault(loc => loc.LocationID == ovm.LocationID).Name }).ToList(); } return View(orders); }
public ActionResult Start(int id) { using (CafeContext context = new CafeContext()) { Order toStart = context.Orders.Single(order => order.OrderID == id); TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); DateTime pacificTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tz); toStart.StartedAt = pacificTime; context.SaveChanges(); ViewBag.UserName = context.UserProfiles.FirstOrDefault(user => user.UserId == toStart.UserID).UserName; return View(OrderToViewModel(toStart)); } }
public ActionResult Process(int id) { IEnumerable<OrderViewModel> orders; using (CafeContext context = new CafeContext()) { //set location name ViewBag.LocationName = context.Locations.FirstOrDefault(loc => loc.LocationID == id).Name; orders = context.Orders.Where(o => o.LocationID == id).Select(ovm => new OrderViewModel() { CancelledAt = ovm.CancelledAt, CompletedAt = ovm.CompletedAt, CreatedAt = ovm.CreatedAt, LocationID = ovm.LocationID, OrderID = ovm.OrderID, PickUpAt = ovm.PickUpAt, StartedAt = ovm.StartedAt, UserID = ovm.UserID, UserName = context.UserProfiles.FirstOrDefault(user => user.UserId == ovm.UserID).UserName }).ToList().OrderBy(order => order.PickUpAt); } return View(orders); }
public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl) { string provider = null; string providerUserId = null; if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId)) { return RedirectToAction("Manage"); } if (ModelState.IsValid) { // Insert a new user into the database using (CafeContext context = new CafeContext()) { UserProfile user = context.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower()); // Check if user already exists if (user == null) { // Insert name into the profile table context.UserProfiles.Add(new UserProfile { UserName = model.UserName }); context.SaveChanges(); OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName); OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false); return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name."); } } } ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName; ViewBag.ReturnUrl = returnUrl; return View(model); }