public async Task <IActionResult> Create([Bind("cars,houses,lands,rentIncomeType,rentIncomeAmount")] Belongings belongings) { if (ModelState.IsValid) { //_context.Add(belongings); //await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); if (TempData["Field"] != null) { belongings.BeneficiarID = (int)TempData.Peek("BenId"); _context.Add(belongings); await _context.SaveChangesAsync(); return(RedirectToAction("ChooseField", "Home")); } CreateModel model = TempData.Get <CreateModel>("model"); model.belongings = belongings; TempData.Put <CreateModel>("model", model); string b = model.belongings.rentIncomeType; return(Redirect("~/Beneficiars/New/AddingInfo/Loans")); } return(View(belongings)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,cars,houses,lands,rentIncomeType,rentIncomeAmount,BeneficiarID")] Belongings belongings) { if (id != belongings.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(belongings); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BelongingsExists(belongings.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("ChooseField", "Home")); // return RedirectToAction(nameof(Index)); } return(View(belongings)); }
public Citizen() { Type = "M"; Name = "Medborgaren"; Belongings.Add(new Sak("Nycklar")); Belongings.Add(new Sak("Mobil")); Belongings.Add(new Sak("Pengar")); Belongings.Add(new Sak("Klocka")); }
public void BuyItem(IItem item, Seller seller) { const string tabs = " "; Console.WriteLine($"{tabs}{Name} bought {seller.Name}'s #{item.SellerItemId} for ${String.Format("{0:0.00}", item.Price)}"); Belongings.Add(item); NumberOfItemsBought++; Balance -= item.Price; AmountUsed += item.Price; }
public RealmStage(Regulus.Remoting.ISoulBinder binder, IScene realm, Regulus.Project.SamebestKeys.Serializable.DBEntityInfomation[] actors, Belongings belongings) { _Binder = binder; this._Scene = realm; _Players = (from actor in actors select new Player(actor)).ToArray(); _Observeds = new List<IObservedAbility>(); _Belongings = belongings; _Updater = new Utility.Updater(); }
public void InitializeGame() { TimeToFlight = 60; Player = new Player(); Player.Initialize(); MakeRooms(); Commands.Clear(); Commands.Add(new Look()); Commands.Add(new Go()); Commands.Add(new CheckIn()); Commands.Add(new SecurityCommand()); CheckedIn = false; GameOver = false; CurrentBelongings = Belongings.Electronics | Belongings.Pockets | Belongings.Backpack | Belongings.Belt | Belongings.Shoes; }
public void SellItems(int numberOfItemsToSell) { if (numberOfItemsToSell > Belongings.Count) { numberOfItemsToSell = Belongings.Count; } numberOfItemsToSell--; var random = new ThreadSafeRandom(); var array = Belongings.ToArray(); while (numberOfItemsToSell >= 0 && array.Length > 0) { var item = array[random.Next(0, numberOfItemsToSell)]; Belongings.Remove(item); _ItemsListedForSale.Add(item); Market.GetInstance().PublishItem(this, item); numberOfItemsToSell--; array = Belongings.ToArray(); } }
public Seller(ISet <IItem> belongings, decimal startBalance, string name) : base(startBalance, name, belongings) { InitialBelongingsCount = belongings.Count; InitialValueOfItems = Belongings.ToList().Sum(s => s.Price); }
public async Task <IActionResult> DeleteConfirmed(int id) { var beneficiar = await _context.Beneficiars.FindAsync(id); Wife wife = _context.Wives.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (wife != null) { Work w1 = _context.works.Where(w => w.WifeID == wife.Id).FirstOrDefault(); if (w1 != null) { _context.works.Remove(w1); } await _context.SaveChangesAsync(); Disease d1 = _context.diseases.Where(w => w.WifeID == wife.Id).FirstOrDefault(); if (d1 != null) { _context.diseases.Remove(d1); } await _context.SaveChangesAsync(); _context.Wives.Remove(wife); } Work w = _context.works.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (w != null) { _context.works.Remove(w); } Belongings b = _context.belongings.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (b != null) { _context.belongings.Remove(b); } Address a = _context.addresses.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (a != null) { _context.addresses.Remove(a); } Loans l = _context.loans.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (l != null) { _context.loans.Remove(l); } SocialHelp s = _context.socialHelps.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (s != null) { _context.socialHelps.Remove(s); } Disease d = _context.diseases.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (d != null) { _context.diseases.Remove(d); } List <Child> children = _context.children.Where(c => c.BeneficiarID == id).ToList(); foreach (Child c in children) { Work w2 = _context.works.Where(w => w.ChildID == c.Id).FirstOrDefault(); if (w2 != null) { _context.works.Remove(w2); } Disease d2 = _context.diseases.Where(w => w.ChildID == c.Id).FirstOrDefault(); if (d2 != null) { _context.diseases.Remove(d2); } await _context.SaveChangesAsync(); _context.children.Remove(c); } await _context.SaveChangesAsync(); _context.Beneficiars.Remove(beneficiar); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task CharacterCard_Should_BeProperlyExportedAndImported() { var investigatorData = new InvestigatorData { Name = "Elisabeth Grimaldi", Player = "Lao", Occupation = new Occupation { Name = "Badacz" }, Age = 26, Gender = Gender.Female, PlaceOfResidence = "Paryż", PlaceOfBirth = "Londyn" }; var characteristics = new Characteristics { Strength = 45, Constitution = 70, Size = 71, Dexterity = 45, Appearance = 60, Intelligence = 55, Power = 55, Education = 65, HitPoints = 14, Luck = 55, MagicPoints = 11 }; var weapons = new System.Collections.ObjectModel.ObservableCollection <Weapon> { new Weapon { Name = "Średni nóż", Damage = "1D4 + 2 + MO", NumberOfAttacks = "1" } }; var history = new InvestigatorHistory { CharacterDescription = "Śliczna" + "Nieśmiała" + "Elegancka", IdeologyAndBeliefs = "Polityka - liberalizm", ImportantPeople = "Nauczyciel medycyny - Emmet Harding" + "ubóstwiam tą osobę za jej niesamowitą inteligencję", ImportantPlaces = "Wieża Eiffela", PersonalThings = "Okrągła, walcowata tuba bez otworu znaleziona pod wejściem do windy wieży Eiffela", Qualities = "Lojalność", InjuriesScars = "10cm blizna na prawej łopatce" }; var belongings = new Belongings { Equipment = new System.Collections.Generic.List <string> { "Książki historyczne", "Średni nóż" }, ExpenditureLevel = 10, Cash = 60, Possesions = new System.Collections.Generic.Dictionary <string, int> { { "mieszkanie w Paryżu", 1500 } } }; var relations = new System.Collections.ObjectModel.ObservableCollection <Relations> { new Relations { Investigator = "Hudson Caffey", Player = "Jasiu", Relation = "kolega, poznany przez Howarda Barnhama" }, new Relations { Investigator = "Mortimer Caffey", Player = "Gerard", Relation = "kolega, poznany przez Howarda Barnhama" }, new Relations { Investigator = "Howard Barnham", Player = "Bartek", Relation = "Poznany 5 lat temu na bankiecie, dobry przyjaciel" } }; var sut = CharacterCard.Create(investigatorData, characteristics, new System.Collections.ObjectModel.ObservableCollection <Skill>(), weapons, history, belongings, relations); await sut.InitializeAsync(); await sut.ExportAsync("CharacterCard.json"); var newSut = new CharacterCard(); await newSut.ImportAsync("CharacterCard.json"); var compareLogic = new CompareLogic(); var result = compareLogic.Compare(sut, newSut); Assert.IsTrue(result.AreEqual); }