private SoldObject MappModel(Sold soldObject) { var namedAreas = new List <NamedArea>(); foreach (var namedArea in soldObject.Location.NamedAreas) { namedAreas.Add(new NamedArea { Area = namedArea }); } var location = new Common.Models.Location { NamedAreas = namedAreas, Position = new Common.Models.Position(soldObject.Location.Position.Latitude, soldObject.Location.Position.Longitude) }; var mappedModel = new SoldObject { BooliId = soldObject.BooliId, AdditionalArea = soldObject.AdditionalArea, LivingArea = soldObject.LivingArea, Location = location, ObjectType = soldObject.ObjectType, Rent = soldObject.Rent, Rooms = soldObject.Rooms, SoldPrice = soldObject.SoldPrice, SoldDate = soldObject.SoldDate }; return(mappedModel); }
public ActionResult Delete(String idDet_Bil) { try { int idProT = Int32.Parse(idDet_Bil.Trim()); Detail_Product pro = db.Detail_Product.FirstOrDefault(a => a.id == idProT); if (pro != null) { Sold sol = db.Solds.FirstOrDefault(a => a.idDetail_Product == pro.id); db.Solds.Attach(sol); db.Solds.Remove(sol); db.SaveChanges(); db.Detail_Product.Attach(pro); db.Detail_Product.Remove(pro); db.SaveChanges(); } } catch (Exception e) { ClassMore.Login_hasLogin = false; return(RedirectToAction("Login", "Home")); } return(RedirectToAction("Index", "Detail_Bill")); }
private void btnPayInvoice_Click(object sender, EventArgs e) { if (saleItemList.Count <= 0) { MessageBox.Show("Please add a product in Cart!"); return; } try { using (var scope = _App.VgmsDb.Database.BeginTransaction()) { if (invoice == null) { invoice = new Invoice(); } invoice.TotalItem = totalInvoiceItem; invoice.TotalSellingPrice = (float)totalInvoicePrice; invoice.CreateById = _App.CurrentUser.Id; invoice.CreateDate = DateTime.Now; invoice.UpdateById = _App.CurrentUser.Id; invoice.UpdateDate = DateTime.Now; _App.VgmsDb.Invoice.Add(invoice); _App.VgmsDb.SaveChanges(); var totalBuyPrice = 0.00; foreach (var item in saleItemList) { var product = _App.VgmsDb.Product.SingleOrDefault(x => x.Id == item.Id); if (product != null) { Sold sold = new Sold(); sold.InvoiceId = invoice.Id; sold.ProductId = item.Id; sold.Quantity = item.Quantity; sold.UnitSellingPrice = (float)item.Unit_Price; sold.TotalPrice = (float)item.Total_Price; sold.SaleDate = DateTime.Now; _App.VgmsDb.Sold.Add(sold); totalBuyPrice += item.Quantity * product.BuyPrice; product.TotalSold += item.Quantity; } } _App.VgmsDb.SaveChanges(); scope.Commit(); CreatPdf(); NewInvoice(); } //open a billing form pass invoice id } catch (Exception ex) { MessageBox.Show("Error!" + ex.GetBaseException()); } }
public ActionResult DeleteConfirmed(int id) { Sold sold = db.Solds.Find(id); db.Solds.Remove(sold); db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Edit(int id, SoldViewModel data) { Sold sold = new Sold(id); sold.Content = data.Content; string originalFile = Server.MapPath(@"/assets/images/sold/" + id.ToString() + "/"); Directory.CreateDirectory(originalFile); if (Request.Files["Thumbnail"].HasFile()) { Request.Files["Thumbnail"].SaveAs(originalFile + Request.Files["Thumbnail"].FileName); sold.Thumbnail = Request.Files["Thumbnail"].FileName; } if (Request.Files["Interior"].HasFile()) { Request.Files["Interior"].SaveAs(originalFile + Request.Files["Interior"].FileName); sold.Interior = Request.Files["Interior"].FileName; } if (Request.Files["Exterior"].HasFile()) { Request.Files["Exterior"].SaveAs(originalFile + Request.Files["Exterior"].FileName); sold.Exterior = Request.Files["Exterior"].FileName; } return(Redirect("/admin/sold")); }
public JsonResult Purchase(int?drink_id) { if (drink_id == null || drink_id < 1) { return(Json(new { success = false, message = "Неправильный код напитка", cash = Settings.AppSettings.Cash }, JsonRequestBehavior.AllowGet)); } Core.Drink drink = Core.Drink.GetEntityById(drink_id.Value); if (drink.price > Settings.AppSettings.Cash) { return(Json(new { success = false, message = "Недостаточно средств", cash = Settings.AppSettings.Cash }, JsonRequestBehavior.AllowGet)); } // Спишем средства со счета Settings.AppSettings.Cash -= drink.price; // Запишем продажу в БД Core.Sold sold = new Sold(); sold.drink_id = drink_id.Value; sold.dt = DateTime.Now; sold.Save(); // Уменьшим количество товара в хранилище Core.Store store = Core.Store.GetEntityById(drink_id.Value); store.qty--; store.Save(); return(Json(new { success = true, message = "success", cash = Settings.AppSettings.Cash }, JsonRequestBehavior.AllowGet)); }
public static void ShowInfo(Sold sold) { Console.WriteLine(string.Format ("Id{0,3} Car: {1,-27} Price: {2,-10 } Amount: {3,3} Date: {4,12}" , sold.IdCar, sold.CarName, sold.PriceCar.ToString("C"), sold.AmountCars, sold.Date.ToShortDateString())); }
public string[] dataGrid(Sold sold) { // return array with all the room properties return(new string[] { sold.afzet.ToString(), sold.omzet.ToString(), sold.aantal_klanten.ToString() }); }
private void btnProdajLek_Click(object sender, EventArgs e) { var db = DataLayer.GetDataBase(); if (numericUpDown1.Value == 0) { MessageBox.Show("Kolicina mora biti veca od 0"); return; } var collectionWorker = db.GetCollection <Worker>("radnici"); Worker w = null; w = collectionWorker.FindOne(Query.EQ("WorkerCode", BsonValue.Create(kodRadnika))); if (w == null) { MessageBox.Show("Ne postoji radnik sa tim kodom"); return; } var collection = db.GetCollection <Medicament>("lekovi"); var query = Query.EQ("_id", BsonValue.Create(idLeka)); Medicament m = collection.FindOne(query); if (numericUpDown1.Value > m.Quantity) { MessageBox.Show("Ne postoji toliko lekova"); return; } var collectionSold = db.GetCollection <Sold>("prodato"); Sold s = new Sold() { DateOfSale = System.DateTime.Now, Quantity = (int)numericUpDown1.Value, Worker = new MongoDBRef("radnici", w.Id), Medicament = new MongoDBRef("lekovi", m.Id) }; collectionSold.Insert(s); int novaKolicina = m.Quantity - (int)numericUpDown1.Value; var update = MongoDB.Driver.Builders.Update.Set("Quantity", BsonValue.Create(novaKolicina)); collection.Update(query, update); numericUpDown1.Value = 0; MessageBox.Show("Uspesno ste prodali lek. Zatvaram..."); this.Close(); }
public async Task <ActionResult> Sell(Sold model) { string message; using (var client = new HttpClient()) { try { client.BaseAddress = new Uri("https://cloud-sse.iexapis.com"); var response = await client.GetAsync($"/stable/stock/{model.Symbol}/quote?token=pk_f7b30f305a8c4aef8eaec49711a8344e"); response.EnsureSuccessStatusCode(); var stringResult = await response.Content.ReadAsStringAsync(); var rawShare = JsonConvert.DeserializeObject <Sold>(stringResult); string userId = User.Claims.First(c => c.Type == "Id").Value; var user = db.ApplicationUsers.Where(au => au.Id == userId).ToList(); List <Bought> shareList = db.Boughts.Where(s => s.Symbol == model.Symbol).Where(s => s.NumOfShare == model.NumOfShare).Where(s => s.IsOwned == true).ToList(); shareList[0].IsOwned = false; db.Boughts.Update(shareList[0]); DateTime date = DateTime.Now; Sold share = new Sold { DateAndTime = date, Symbol = shareList[0].Symbol, companyName = shareList[0].companyName, latestPrice = rawShare.latestPrice, NumOfShare = shareList[0].NumOfShare, Cost = shareList[0].latestPrice, Profit = rawShare.latestPrice - shareList[0].latestPrice, AspNetUserId = user[0].Id }; user[0].Fund = user[0].Fund + model.NumOfShare * (rawShare.latestPrice - shareList[0].latestPrice); await userManager.UpdateAsync(user[0]); db.Solds.Add(share); db.SaveChanges(); message = "Sold!"; return(Ok(new { message })); } catch (HttpRequestException httpRequestException) { return(BadRequest(new { httpRequestException.Message })); } } }
private void btnSell_Click(object sender, EventArgs e) { order.Date = txtDate.Value; order.BillNo = txtBill.Text; order.sellCount = (int)numQuantity.Value; order.Price = float.Parse(txtPrice.Text); order.UpdateCount(order.Quantity - (int)numQuantity.Value); Sold.Invoke(order); this.Hide(); }
public ActionResult DetailsSoldProduct(int id) { Sold rg = db.sales.Find(id); if (rg != null) { return(View()); } return(RedirectToAction("Table")); }
// Omzet rapport public Sold getRapport(long startDate, long endDate) { // call the dao to get the afzet, omzet and aantal_klanten Int32 afzet = dao.getAfzet(startDate, endDate); double omzet = dao.getOmzet(startDate, endDate); Int32 aantal_klanten = dao.getSoldCustomers(startDate, endDate); // return a rapport Sold sold = new Sold(afzet, omzet, aantal_klanten); return(sold); }
public void Sell(Vendor currentVendor) { if (Sold.Equals(false)) { Sold = true; SoldDate = DateTime.Now; SoldBy = currentVendor; } else { Console.WriteLine($"The item {Number} cannot be sold a second time."); } }
public ActionResult Edit([Bind(Include = "SaleID,TrackerID,LocID,AppID,Validate")] Sold sold) { if (ModelState.IsValid) { db.Entry(sold).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.LocID = new SelectList(db.Locats, "LocID", "LocDetails", sold.LocID); ViewBag.AppID = new SelectList(db.Vehicles, "AppID", "VehicleDet", sold.AppID); ViewBag.TrackerID = new SelectList(db.Trackers, "TrackerID", "Statuss", sold.TrackerID); return View(sold); }
// GET: Solds/Details/5 public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Sold sold = db.Solds.Find(id); if (sold == null) { return HttpNotFound(); } return View(sold); }
private void AddButton(object obj) { if (Convert.ToInt32(Sold.Number) <= Convert.ToInt32(Controller.Number)) { Sold.NumberSold += Convert.ToInt32(Controller.Number); AddToList(Sold); Sold.Number = Convert.ToInt32(Sold.Number) - Sold.NumberSold; Sold.UpdateButton(); ((Window)obj).Close(); } else { MessageBox.Show($"На складі є {Sold.Number}"); } }
public ActionResult <Grocery.Models.Grocery> LoanBook([FromRoute] int id, [FromBody] Sold loan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var prd = _context.Grocery.Find(id); if (prd == null) { return(BadRequest()); } prd.IsSold = true; _context.SaveChanges(); return(Ok(prd)); }
// GET: Solds/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Sold sold = db.Solds.Find(id); if (sold == null) { return HttpNotFound(); } ViewBag.LocID = new SelectList(db.Locats, "LocID", "LocDetails", sold.LocID); ViewBag.AppID = new SelectList(db.Vehicles, "AppID", "VehicleDet", sold.AppID); ViewBag.TrackerID = new SelectList(db.Trackers, "TrackerID", "Statuss", sold.TrackerID); return View(sold); }
private void DG_Sold_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { if (DG_Sold.SelectedCells.Count > 0 && DG_Sold.SelectedCells[0].IsValid) { Sold t = DG_Sold.SelectedItem as Sold; DeleteSold window = new DeleteSold(t.Id); window.ShowDialog(); RefreshDG(); } } catch (Exception err) { MessageBox.Show(err.Message); } }
private void btnYes_Click(object sender, RoutedEventArgs e) { try { using (ApplicationDBContext context = new ApplicationDBContext()) { Sold v = (from a in context.Solds where a.Id == _id select a).FirstOrDefault(); if (v != null) { Partiya p = (from a in context.Partiyas .Include(x => x.Product) .Include(x => x.Product.Massa) .Include(x => x.Product.Types) where v.PartiyaId == a.Id select a).FirstOrDefault(); p.CountProduct += v.CountProduct; Vazvrat t = new Vazvrat() { Tovar = p.Product.NameOfProduct, Shtrix = p.Product.Shtrix, MassaName = p.Product.Massa.Name, TypeName = p.Product.Types.TypeName, CountProduct = v.CountProduct }; context.Vazvrats.Add(t); context.Solds.Remove(v); context.SaveChanges(); this.Close(); } else { MessageBox.Show("Этот товар не найден в базе"); } } } catch (Exception ex) { MessageBox.Show("Error44"); } }
public override bool onEnter() { m_key = new BuyChildKey(); m_key.init(this); var _key = m_key as BuyChildKey; m_key.registerCallBack(this.UpLevel.GetComponent <Button>(), btnOnUpLevelClick); m_key.registerCallBack(this.Sold.GetComponent <Button>(), btnOnSoldClick); m_key.registerCallBack(this.Recover.GetComponent <Button>(), btnOnRecoverClick); m_key.registerCallBack(this.Move.GetComponent <Button>(), btnOnMoveClick); UpLevel.transform.Find("Text").GetComponent <Text>().color = ColorTypeChange.Instance.HexColorToColor("f99629"); m_key.RegisterOnKeyChangedEvent(UpLevel.GetComponent <Button>(), btnOnEnter, btnOnExit); m_key.RegisterOnKeyChangedEvent(Sold.GetComponent <Button>(), btnOnEnter, btnOnExit); m_key.RegisterOnKeyChangedEvent(Recover.GetComponent <Button>(), btnOnEnter, btnOnExit); m_key.RegisterOnKeyChangedEvent(Move.GetComponent <Button>(), btnOnEnter, btnOnExit); p = BattleManager.getMe().leftPlayer; //ColorUtility.TryParseHtmlString("f99629", out selectColor); // text = transform.Find("Text").GetComponent<Text>(); return(true); }
private void btngetRapport_Click(object sender, EventArgs e) { // get the start and end date of selected range DateTime start = RapportCalender.SelectionRange.Start; DateTime end = RapportCalender.SelectionRange.End; // get rapport and convert date to amount of ticks try { SomerenLogic.Drink_Service drinkService = new SomerenLogic.Drink_Service(); Sold sold = drinkService.getRapport(start.Ticks, end.Ticks); // clear the DataGridView and fill the column names ClearDataGridView(); generateGridLayout(sold.dataGridList()); // Fill the DataGridView with all the rooms using a foreach FillDataInGridView(sold.dataGrid(sold)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult updateBidTime2(String timer2, String id2, String price2, String counter2) { float fl = float.Parse(price2); int id1 = Int32.Parse(id2); int id4 = Int32.Parse(timer2); int cc = Int32.Parse(counter2); Product prd = db.products.Find(id1); String buyer = (string)(Session["log"]); if (prd != null) { if (id4 >= 0) { prd.CountClick = cc; prd.BiddingPrice = fl; prd.BiddingTime = id4; db.Entry(prd).State = EntityState.Modified; db.SaveChanges(); } if (id4 == 0 && cc > 0) { if (i3 == 0) { prd.Status = "sold"; String time = System.DateTime.Now.ToShortDateString(); prd.Date = time; prd.BuyerName = pr3buyer; prd.BiddingTime = 0; db.Entry(prd).State = EntityState.Modified; db.SaveChanges(); Sold soldproduct = new Sold(); soldproduct.BuyerName = pr3buyer; soldproduct.productID = prd.productID; soldproduct.SellerName = prd.SellerName; soldproduct.FileName = prd.FileName; soldproduct.ImageData = prd.ImageData; soldproduct.Price = prd.BiddingPrice; soldproduct.Date = prd.Date; db.sales.Add(soldproduct); db.SaveChanges(); i3 = 1; string a = null; var r = db.reg.Where(v => v.UserName.Equals(pr1buyer)); foreach (var item in r) { a = item.Email; } SmtpClient smtp = new SmtpClient(" smtp.gmail.com", 587); smtp.EnableSsl = true; smtp.Timeout = 100000; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("*****@*****.**", "eauction 597"); MailMessage message = new MailMessage(); message.To.Add(a); message.From = new MailAddress("*****@*****.**"); message.Subject = "LIVE BID WINNER!"; message.Body = "Your are the higest bidder for the product " + prd.ProductName + ". Please contact us ASAP for delivery & payment procedure.Thanks"; System.Diagnostics.Debug.WriteLine(a + message.Body); smtp.Send(message); string ab = null; var r1 = db.reg.Where(v => v.UserName.Equals(soldproduct.SellerName)); foreach (var item in r) { ab = item.Email; } SmtpClient smtp1 = new SmtpClient(" smtp.gmail.com", 587); smtp1.EnableSsl = true; smtp1.Timeout = 100000; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("*****@*****.**", "eauction 597"); MailMessage message1 = new MailMessage(); message1.To.Add(ab); message1.From = new MailAddress("*****@*****.**"); message1.Subject = "LIVE BID PRODUCT SOLD!"; message1.Body = "Your product " + prd.ProductName + " has been sold for the price " + soldproduct.Price + ". Please contact us ASAP for further Information.Thanks"; smtp.Send(message1); } } if (id4 == 0 && cc == 0) { prd.Status = "unsold"; db.Entry(prd).State = EntityState.Modified; db.SaveChanges(); } } return(View()); }
private void btnOK_Click(object sender, RoutedEventArgs e) { using (ApplicationDBContext context = new ApplicationDBContext()) { #region if ((Convert.ToInt32(txtPlastik.Text) + Convert.ToInt32(txtNaqt.Text) + Convert.ToInt32(txtQarz.Text)) == Convert.ToInt32(_SkidkaSum)) { if (checkQarz.IsChecked == true) { if (txtQarz.Text != "0" && txtQarz.Text != "") { var q = (from a in context.DebtInfos where a.FIO == txtFIO_Qarzdor.Text select a).FirstOrDefault(); if (q != null) { Income i = new Income() { CashIncome = Convert.ToDecimal(txtNaqt.Text), PlasticIncome = Convert.ToDecimal(txtPlastik.Text), DateTimeNow = DateTime.Now, DebtIncome = 0, DebtOut = Convert.ToDecimal(txtQarz.Text), SaleProductPrice = Convert.ToDecimal(_AllSum), SaleProductWithDiscountPrice = Convert.ToDecimal(_SkidkaSum), Vozvrat = 0, WorkerId = Properties.Settings.Default.UserId }; Debt d = new Debt() { dateTimeFrom = DateTime.Now, dateTimeUntil = (DateTime)date1.SelectedDate, Price = Convert.ToDecimal(txtQarz.Text), DebtInfoId = q.Id }; context.Incomes.Add(i); context.Debts.Add(d); var o = (from b in context.Kassas .Include(x => x.Partiya) .Include(x => x.Partiya.Product) .Include(x => x.Partiya.Product.Massa) .Include(x => x.Partiya.Product.Types) .Include(x => x.Partiya.Provider) where b.WorkerID == Properties.Settings.Default.UserId select b).ToList(); /* * Check chiqarish uchun kod */ if (checkPrintCheck.IsChecked == true) { Print(); } /* */ foreach (var t in o) { Sold s = new Sold() { ProductId = t.Partiya.Product.Id, Shtrix = t.Partiya.Product.Shtrix, NameOfProduct = t.Partiya.Product.NameOfProduct, PartiyaId = t.Partiya.Id, BazaPrice = t.Partiya.BazaPrice, SalePrice = t.Partiya.SalePrice, CountProduct = t.CountProduct, ProviderId = t.Partiya.Provider.Id, ProviderName = t.Partiya.Provider.ProviderName, MassaId = t.Partiya.Product.Massa.Id, MassaName = t.Partiya.Product.Massa.Name, TypeId = t.Partiya.Product.Types.Id, TypeName = t.Partiya.Product.Types.TypeName, AllSumma = t.AllPrice, WorkerId = Properties.Settings.Default.UserId, dateTimeNow = DateTime.Now }; context.Solds.Add(s); var y = (from c in context.Partiyas .Include(x => x.Product) where t.Partiya.Id == c.Id select c).FirstOrDefault(); y.CountProduct -= t.CountProduct; context.Kassas.Remove(t); } MainWindow m = new MainWindow(); m.labSkidka.Text = "0"; m.txtSkidkaSumm.Text = "0"; context.SaveChanges(); this.Close(); } } else { MessageBox.Show("Ошибка с долгом!"); } } else { Income i = new Income() { CashIncome = Convert.ToDecimal(txtNaqt.Text), PlasticIncome = Convert.ToDecimal(txtPlastik.Text), DateTimeNow = DateTime.Now, DebtIncome = 0, DebtOut = Convert.ToDecimal(txtQarz.Text), SaleProductPrice = Convert.ToDecimal(_AllSum), SaleProductWithDiscountPrice = Convert.ToDecimal(_SkidkaSum), Vozvrat = 0, WorkerId = Properties.Settings.Default.UserId }; context.Incomes.Add(i); var o = (from b in context.Kassas .Include(x => x.Partiya) .Include(x => x.Partiya.Product) .Include(x => x.Partiya.Product.Massa) .Include(x => x.Partiya.Product.Types) .Include(x => x.Partiya.Provider) where b.WorkerID == Properties.Settings.Default.UserId select b).ToList(); /* * Check chiqarish uchun kod */ if (checkPrintCheck.IsChecked == true) { Print(); } /* */ foreach (var t in o) { Sold s = new Sold() { ProductId = t.Partiya.Product.Id, Shtrix = t.Partiya.Product.Shtrix, NameOfProduct = t.Partiya.Product.NameOfProduct, PartiyaId = t.Partiya.Id, BazaPrice = t.Partiya.BazaPrice, SalePrice = t.Partiya.SalePrice, CountProduct = t.CountProduct, ProviderId = t.Partiya.Provider.Id, ProviderName = t.Partiya.Provider.ProviderName, MassaId = t.Partiya.Product.Massa.Id, MassaName = t.Partiya.Product.Massa.Name, TypeId = t.Partiya.Product.Types.Id, TypeName = t.Partiya.Product.Types.TypeName, AllSumma = t.AllPrice, WorkerId = Properties.Settings.Default.UserId, dateTimeNow = DateTime.Now }; context.Solds.Add(s); var y = (from c in context.Partiyas .Include(x => x.Product) where t.Partiya.Id == c.Id select c).FirstOrDefault(); y.CountProduct -= t.CountProduct; context.Kassas.Remove(t); } MainWindow m = new MainWindow(); m.labSkidka.Text = "0"; m.txtSkidkaSumm.Text = "0"; this.Close(); context.SaveChanges(); } } #endregion } }
// ---------------------------------------------------------------------------- Main() --------------- public static void Main(string[] args) { Sold player = new Sold(); Write("Hello and welcome to MSSA SD7 roulette game."); SkipLines(2); Write("(1) Bet on color."); //done Write("\n(2) Even or Odds?"); Write("\n(3) Lows/Highs: low (1 - 18) or high (19 - 38) numbers."); Write("\n(4) Columns: first, second, or third columns."); Write("\n(5) Dozens: row thirds, 1 - 12, 13 - 24, 25 - 36"); Write("\n(6) Street: rows, e.g., 1/2/3 or 22/23/24"); Write("\n(7) 6 Numbers: double rows, e.g., 1/2/3/4/5/6 or 22/23/24/25/26/26"); Write("\n(8) Split: at the edge of any two contiguous numbers, e.g., 1/2, 11/14, and 35/36"); Write("\n(9) Corner: at the intersection of any four contiguous numbers, e.g., 1/2/4/5, or 23/24/26/27"); Write("\n(10) Numbers: the number of the bin"); Console.Write("\n\nEnter game number: "); int activeGame = int.Parse(Console.ReadLine()); Console.Write($"You chose game #{activeGame}. Hit Enter to play."); Console.ReadLine(); switch (activeGame) { case 1: Console.WriteLine("Game 1"); Write("\nYou start the game with 100$.\nYou can bet on a number or on a color.\nBet on color will multiply your bet by 2 where a number bet will multiply it by 5.\nTo bet, just write a number between 1 & 36 or red or black.\nGood luck and have fun :)\n"); SkipLines(1); while (true) { try { SkipLines(1); player.ShowSold(); Write("Bet ? "); gamble = Convert.ToInt32(Conv()); } catch (Exception) { Write("You have to gamble so your bet is 10.\n"); gamble = 10; } player.Sub(ref gamble); int randomNumber = GetRandomNumber(rand); int mult = 0; Write("On what ? "); string write = Conv().ToLower(); if (write.Equals("red")) { mult = ColorWin(randomNumber, red_nums); } else if (write.Equals("black")) { mult = ColorWin(randomNumber, black_nums); } else { try { int bet = Convert.ToInt32(write); mult = IntWin(bet, randomNumber); } catch (Exception) { Write("Wrong input, lost your bet."); } } player.Add(gamble * mult); if (player.CheckForGameOver()) { goto defeat; } } defeat: SkipLines(2); Write("You lost, try again another time :D"); break; case 2: Console.WriteLine("Game 2"); goto case 1; //TODO need to update //break; case 3: Console.WriteLine("Game 3"); goto case 1; //TODO need to update //break; case 4: Console.WriteLine("Game 4"); goto case 1; //TODO need to update //break; case 5: Console.WriteLine("Game 5"); goto case 1; //TODO need to update //break; case 6: Console.WriteLine("Game 6"); goto case 1; //TODO need to update //break; case 7: Console.WriteLine("Game 7"); goto case 1; //TODO need to update //break; case 8: Console.WriteLine("Game 8"); goto case 1; //TODO need to update //break; case 9: Console.WriteLine("Game 9"); goto case 1; //TODO need to update //break; case 10: Console.WriteLine("Game 10"); goto case 1; //goto: Used for in replacement of break. //break; } }
public SingletonSold() { Sold = new Sold(); }
public async Task <IActionResult> ConfirmOrder(string Id) { int invoice_id = int.Parse(Id); string userId = _userManager.GetUserId(HttpContext.User); ApplicationUser user = await _userManager.FindByIdAsync(userId); Address address = _appDbContext.Addresses.Find(userId); PaymentMethod paymentMethod = _appDbContext.PaymentMethods.Find(userId); /* * If Both Address and PaymentMethod are empty, * The customer will be redirected to his profile * to fill address (For Shipping purpose), * and paymentMethod (For Invoice Payment) */ if (address == null || paymentMethod == null) { /* In the future, i should add message with redirection, * to indicate what information to be filled */ return(RedirectToAction("UserInformation", "Profile")); } var invoice = _appDbContext.Invoices.Single(i => i.ApplicationUserId == userId && i.Id == invoice_id); if (invoice == null) { return(NotFound()); } var authResult = await _authorizationService.AuthorizeAsync(User, invoice, CRUD.Update); if (authResult.Succeeded) { invoice.IsConfirmed = true; var inv = _appDbContext.Invoices.Attach(invoice); inv.State = EntityState.Modified; await _appDbContext.SaveChangesAsync(); // Implement: Product-Sold logic List <ProductSold> productSoldList = new List <ProductSold>(); var productList = _appDbContext.InvoiceProduct .Where(i => i.InvoiceId == invoice.Id) .Select(p => new InvoiceProductInfo { Product = p.Product, Qty = p.Qty, Invoice = p.Invoice }).ToList(); foreach (var product in productList) { var sold = new Sold { Qty = product.Qty }; await _appDbContext.Solds.AddAsync(sold); await _appDbContext.SaveChangesAsync(); var productSold = new ProductSold { SoldId = sold.Id, ProductId = product.Product.Id }; productSoldList.Add(productSold); } await _appDbContext.ProductSolds.AddRangeAsync(productSoldList); await _appDbContext.SaveChangesAsync(); return(RedirectToAction("UserOrders", "Profile")); } else if (User.Identity.IsAuthenticated) { return(new ForbidResult()); } else { return(new ChallengeResult()); } }
public override void update(float elapsedTime) { cSoldados = ControladorJuego.getInstance().soldados; PosicionActual = this.mesh3.Position; Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice; this.mesh3.move(direccion * velocidad * elapsedTime); float distancia; distancia = calcularDistancia(posicionInicial, this.PosicionActual); foreach (Soldado Sold in cSoldados) { if (calcularColisionPersonaje(mesh3, Sold.mesh) && explota < 3) { explotando = true; ExplotoX = Sold.mesh.Position.X; ExplotoZ = Sold.mesh.Position.Z; break; } } if (explota >= 3) { explotando = false; explota = 0; } if (explotando) { explota += elapsedTime; } foreach (Soldado Sold in cSoldados) { if (Sold.vive()) { if (!calcularColisionPersonaje(mesh3, Sold.mesh)) { this.mesh3.move(direccion * velocidad * elapsedTime); } else { acerto = true; meshSoldado = Sold; Sold.matar(); i++; break; } } } // Cuando el misil le da a un soldado lo mata y deja rastros de fuego if (acerto && meshSoldado.Persigue) { Random r = new Random(DateTime.Now.Millisecond); meshSoldado.matar(); meshSoldado.mesh.rotateZ(250); meshSoldado.Persigue = false; acerto = false; } //Elimino la bola al colisionar con el terreno List <TgcMesh> meshesTerreno = ControladorJuego.getInstance().Escenario.terreno.Meshes; //meshSoldado.moveOrientedY(8); // meshSoldado.Position = new Vector3(meshSoldado.Position.X, meshSoldado.Position.Y + 15, meshSoldado.Position.Z) * elapsedTime; // //meshSoldado.p //meshSoldado.Position = new Vector3 (meshSoldado.Position.X, meshSoldado.Position.Y, meshSoldado.Position.Z); acerto = false; }