public void ToStringReturnsCorrectResult(MoneyViewModel sut) { // Fixture setup var expectedResult = string.Format("{0} {1:F}", sut.CurrencyCode, sut.Amount); // Exercise system var result = sut.ToString(); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void AmountIsProperWritableProperty(decimal expectedAmount, MoneyViewModel sut) { // Fixture setup // Exercise system sut.Amount = expectedAmount; decimal result = sut.Amount; // Verify outcome Assert.Equal(expectedAmount, result); // Teardown }
public void PriceIsProperWritableProperty(MoneyViewModel expectedPrice, ProductViewModel sut) { // Fixture setup // Exercise system sut.UnitPrice = expectedPrice; MoneyViewModel result = sut.UnitPrice; // Verify outcome Assert.Equal(expectedPrice, result); // Teardown }
public void CurrencyIsProperWritableProperty(string expectedCurrency, MoneyViewModel sut) { // Fixture setup // Exercise system sut.CurrencyCode = expectedCurrency; string result = sut.CurrencyCode; // Verify outcome Assert.Equal(expectedCurrency, result); // Teardown }
public void InsertAccount(MoneyViewModel model) { this._db.StartTransaction(); this._db.AccountBookRepository.Insert(new AccountBook() { Id = Guid.NewGuid(), Categoryyy = (int)model.Category - 1, Amounttt = model.Amount, Dateee = model.Date, Remarkkk = model.Description }); this._db.Commit(); }
public MoneyViewModel Map(WPFInjection.MoneyContract contract) { if (contract == null) { throw new ArgumentNullException("contract"); } var vm = new MoneyViewModel(); vm.Amount = contract.Amount; vm.CurrencyCode = contract.CurrencyCode; return(vm); }
public ActionResult MyAccount(MoneyViewModel pAccData) { ViewData["CateList"] = _CateList; if (ModelState.IsValid) { //存檔 _mSvc.SaveAccount(pAccData); _mSvc.Save(); ModelState.Clear(); return(View(new MoneyViewModel())); } return(View(pAccData)); }
public ActionResult Money([Bind(Prefix = "Money")] MoneyViewModel PageData) { if (!string.IsNullOrWhiteSpace(PageData.category) && !string.IsNullOrWhiteSpace(PageData.date)) { Repository.VMPrository.Add(PageData); } var result = new Combine() { Money = PageData, Moneys = Repository.VMPrository }; return(View(result)); }
public async Task ReturnsCorrectViewResult() { //Arrange const int stakeAmountNative = 20; const int stakeInUSD = 10; const int balAmount = 50; const int M = 4; const int N = 5; const decimal coeff = 0; const string uId = "dawda"; var userManagerMock = new Mock <IUserManager <User> >(); userManagerMock .Setup(umm => umm.GetUserId(It.IsAny <ClaimsPrincipal>())) .Returns(uId); var balanceInfo = new MoneyViewModel { Amount = balAmount }; var userServicesMock = new Mock <IUserServices>(); userServicesMock .Setup(usm => usm.GetBalanceInformation(uId)) .ReturnsAsync(balanceInfo); userServicesMock .Setup(usm => usm.UpdateUserBalanceByAmount(It.IsAny <decimal>(), uId)) .ReturnsAsync(stakeInUSD); var transactionServicesMock = new Mock <ITransactionServices>(); var slotMatix = new List <List <GameItemChanceOutOf100> >(); var slotGamesServicesMock = new Mock <ISlotGamesServices>(); slotGamesServicesMock .Setup(sgsm => sgsm.Run(N, M)) .Returns(slotMatix); slotGamesServicesMock .Setup(sgsm => sgsm.Evaluate(slotMatix)) .Returns(coeff); var jsonConverterMock = new Mock <IJsonConverter>(); var sut = new HomeController(userManagerMock.Object, transactionServicesMock.Object, userServicesMock.Object, slotGamesServicesMock.Object, jsonConverterMock.Object); //Act var result = await sut.SlotGame(new SlotGameViewModel { M = M, N = N, Stake = stakeAmountNative }); //Assert Assert.IsInstanceOfType(result, typeof(JsonResult)); }
public ActionResult Index([Bind(Include = "Type,Date,Price,Description")] MoneyViewModel model) { ViewData["CategoryItems"] = GetCategoryList(); ViewData["PageItems"] = GetPageDropDownList(); /***不知道為什麼model裡面的Type都是None???***/ if (ModelState.IsValid) { _imoneyService.Add(model); _unitOfWork.Commit(); return(RedirectToAction("Index")); } return(View(model)); }
public int addAcc(MoneyViewModel anAccount) { AccountBook accountBook = new AccountBook(); // 產流水號 accountBook.Id = Guid.NewGuid(); accountBook.Categoryyy = int.Parse(anAccount.Type); accountBook.Dateee = anAccount.Datetime ?? DateTime.Now; accountBook.Amounttt = anAccount.Amount; accountBook.Remarkkk = anAccount.Note; var repo = _accRepo.AddAccount(accountBook); return(repo); }
public DeclareWarInformationsViewModel(Entities.Country declaringCountry, double goldNeeded, List <Entities.Country> attackerAllies, List <Entities.Country> defenderAllies) { GoldNeeded = new MoneyViewModel(CurrencyTypeEnum.Gold, (decimal)goldNeeded); foreach (var ally in attackerAllies) { AttackerAllies.Add(new ShortCountryInfoViewModel(ally)); } foreach (var ally in defenderAllies) { DefenderAllies.Add(new ShortCountryInfoViewModel(ally)); } CountryGold = new MoneyViewModel(declaringCountry.Entity.Wallet.GetMoney(CurrencyTypeEnum.Gold, Persistent.Currencies.GetAll())); CountryName = declaringCountry.Entity.Name; }
public HotelSummaryViewModel(Hotel hotel) : base(SessionHelper.Session) { var entity = hotel.Entity; var countryCurrency = Persistent.Countries.GetCountryCurrency(hotel.Region.CountryID.Value); var money = entity.Wallet.GetMoney(countryCurrency.ID, Persistent.Currencies.GetAll()); var adminMoney = entity.Wallet.GetMoney(CurrencyTypeEnum.Gold, Persistent.Currencies.GetAll()); CountryMoney = new MoneyViewModel(money); AdminMoney = new MoneyViewModel(adminMoney); Avatar = new ImageViewModel(entity.ImgUrl); ID = entity.EntityID; Name = entity.Name; }
MoneyViewModel GetMoneyModel() { MoneyViewModel m = new MoneyViewModel(); var db = new ApplicationDbContext(); var u = db.Users.Find(User.Identity.GetUserId()); m.AsMoneyAccount = u.AsmoneyAccount; m.BitcoinAddress = u.BitcoinAddress; m.LitecoinAddress = u.LitecoinAddress; m.PerfectMoney = u.PerfectMoney; db.Dispose(); return(m); }
public EmbargoViewModel(Embargo embargo, IEmbargoService embargoService) { EmbargoID = embargo.ID; CountryName = embargo.EmbargoedCountry.Entity.Name; CountryID = embargo.EmbargoedCountryID; CountryFlag = Images.GetCountryFlag(CountryID).VM; CreatorCountryName = embargo.CreatorCountry.Entity.Name; CreatorID = embargo.CreatorCountryID; CreatorFlag = Images.GetCountryFlag(CreatorID).VM; StartDateTime = string.Format("day {0} {1}", embargo.StartDay, embargo.StartTime.ToShortTimeString()); Upkeep = new MoneyViewModel(CurrencyTypeEnum.Gold, (decimal)embargoService.GetEmbargoCost(embargo.CreatorCountry, embargo.EmbargoedCountry)); }
public void Edit(Guid id, MoneyViewModel vo) { if (vo != null)//這命名好爛..... { //你用 GetSingle 沒拿到就拋例外了,後面的檢查不會跑到 var oldData = _accountBookRepository.GetSingle(a => a.Id == id); if (oldData != null) { oldData.Amounttt = vo.Price; oldData.Categoryyy = vo.Type == CategoryType.Expenditure ? 0 : 1; oldData.Dateee = vo.Date; oldData.Remarkkk = vo.Description; } } }
public void Add(MoneyViewModel vo) { if (vo != null) { AccountBook accountBook = new AccountBook { Id = Guid.NewGuid(),//既然你沒有要傳出去,你宣告變數幹啥? Amounttt = vo.Price, Categoryyy = vo.Type == CategoryType.Expenditure ? 0 : 1, Dateee = vo.Date, Remarkkk = vo.Description }; _accountBookRepository.Create(accountBook); } }
public ActionResult Record(MoneyViewModel data) { var records = db.AccountBook .OrderByDescending(x => x.Dateee) .Take(7) .Select(x => new MoneyViewModel { category = x.Categoryyy, money = x.Amounttt, date = x.Dateee, remark = x.Remarkkk } ); return(View(records)); }
public CitizenSummaryViewModel(CitizenSummaryInfo info, ICitizenService citizenService) { Name = info.Name; CitizenID = info.ID; CanWork = info.CanWork; HitPoints = info.HitPoints; Experience = info.Experience; Trained = info.Trained; Strength = info.Strength; Avatar = new ImageViewModel(info.AvatarUrl); JobID = info.JobID; EatingSafety = info.EatingSafety; CountryMoney = new MoneyViewModel(info.CountryCurrencyID, (decimal)info.CountryMoneyAmount); AdminMoney = new MoneyViewModel(CurrencyTypeEnum.Gold, (decimal)info.GoldAmount); CountryID = info.CountryID; NextExperienceLevel = citizenService.CalculateExperienceForNextLevel(info.Level); ExperienceProgress = (int)(info.Experience / (double)NextExperienceLevel * 100.0); int militaryRank = (int)info.MilitaryRank; int nextMilitaryRank = MilitaryRankEnumExtensions.CalculateNextMilitaryRankNeeded(militaryRank) ?? militaryRank; MilitaryRank = militaryRank.ConvertToBasicUnits(); NextMilitaryRank = nextMilitaryRank.ConvertToBasicUnits(); NextMilitaryRankProgress = (int)(militaryRank / (double)nextMilitaryRank * 100.0); UnreadMessages = info.UnreadMessages; UnreadWarnings = info.UnreadWarnings; if (HitPoints < 90 && info.CanHeal) { CanHeal = info.CanHeal; HealCurrency = CountryMoney.Symbol; HospitalID = info.HospitalID.Value; FreeHealing = info.HealingCost.HasValue == false; if (FreeHealing == false) { HealCost = (double)info.HealingCost.Value; } } }
public ActionResult Index(MoneyViewModel recordViewModel) { if (ModelState.IsValid) { _skillTree.AccountBooks.Add(new AccountBook() { Id = Guid.NewGuid(), Remarkkk = recordViewModel.RecordInput.Remarks, Amounttt = (int)recordViewModel.RecordInput.Money, Categoryyy = (int)recordViewModel.RecordInput.Type, Dateee = recordViewModel.RecordInput.Date }); _skillTree.SaveChanges(); ModelState.Clear(); return(RedirectToAction("Index")); } return(View(recordViewModel)); }
public ActionResult _AccountInput(MoneyViewModel anAccount) { var res = new { Code = "", Message = "", }; if (!ModelState.IsValid) { var errorMessage = ModelState. Values. SelectMany(v => v.Errors) .Select(e => e.ErrorMessage); res = new { Code = "0001", Message = string.Join(",", errorMessage), }; return(Json(res)); } var retu = _accService.addAcc(anAccount); if (retu != 0) { res = new { Code = "0000", Message = "", }; return(Json(res)); } else { res = new { Code = "0001", Message = "後台新增失敗", }; return(Json(res)); } }
private void initialize(int countryID) { loadCountryList(countryID); var entityRepository = DependencyResolver.Current.GetService <IEntityRepository>(); var walletService = DependencyResolver.Current.GetService <IWalletService>(); var countryRepository = DependencyResolver.Current.GetService <ICountryRepository>(); CanSeeTreasury = countryRepository.GetCountryPolicySetting(countryID, p => p.TreasuryVisibilityLawAllowHolderID) != (int)LawAllowHolderEnum.President; if (CanSeeTreasury) { var countryEntity = entityRepository.GetById(countryID); var gold = walletService.GetWalletMoney(countryEntity.WalletID, GameHelper.Gold.ID); CountryGold = new MoneyViewModel(gold); } }
public ActionResult Index(MoneyViewModel moneyData) { if (!ModelState.IsValid) { return(View()); } var accountBook = new AccountBook { Amounttt = Convert.ToInt32(moneyData.MNY), Categoryyy = moneyData.IO == "支出" ? 1 :0, Dateee = moneyData.CHDT, Remarkkk = moneyData.RMK, Id = Guid.NewGuid() }; db.AccountBook.Add(accountBook); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Index(MoneyViewModel money) { if (ModelState.IsValid) { var db = new SkillTreeHomework(); var accountBook = new AccountBook(); accountBook.Id = Guid.NewGuid(); accountBook.Amounttt = (int)money.Amount; accountBook.Categoryyy = (int)money.MoneyType; accountBook.Dateee = money.Date; // TODO : Remarkkk沒填資料會出現 錯誤,資料是 空字串、空白符號,也不行,暫時填上 ? accountBook.Remarkkk = money.Description != null ? money.Description : "?"; db.AccountBook.Add(accountBook); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public ActionResult EditMoney(MoneyViewModel model) { ViewBag.ReturnUrl = Url.Action("Manage"); if (ModelState.IsValid) { var db = new ApplicationDbContext(); var u = db.Users.Find(User.Identity.GetUserId()); u.AsmoneyAccount = model.AsMoneyAccount; u.BitcoinAddress = model.BitcoinAddress; u.LitecoinAddress = model.LitecoinAddress; u.PerfectMoney = model.PerfectMoney; db.SaveChanges(); db.Dispose(); return(RedirectToAction("Manage", new { Message = ManageMessageId.EditSuccess })); } // If we got this far, something failed, redisplay form return(View(model)); }
public IActionResult InsertMoney(string id, [FromBody] MoneyViewModel money) { try { var snackMachine = _snackMachineRepository.GetSnackMachine(id); if (snackMachine == null) { return(new NotFoundResult()); } snackMachine.InsertMoney(money.ConvertToMoney()); return(Ok(_snackMachineRepository.UpdateSnackMachine(snackMachine))); } catch { return(new BadRequestResult()); } }
public IActionResult LoadMoney(string id, [FromBody] MoneyViewModel model) { try { var atm = _atmRepository.GetATM(id); if (atm == null) { return(new NotFoundResult()); } atm.LoadMoney(model.ConvertToMoney()); return(Ok(_atmRepository.UpdateATM(atm))); } catch (Exception ex) { return(new BadRequestResult()); } }
public JsonResult GetAtmChange(int amount, string currencyName) { List <MoneyViewModel> listMoneyToDisplay = new List <MoneyViewModel>(); try { //Check valid parameters if (amount == 0 || String.IsNullOrEmpty(currencyName)) { throw new Exception("Invalid parameters passed to the method"); } //Get the list of money List <Money> listAllMoney = AtmHelper.CalculateChange(currencyName, amount); List <Money> listDistinctMoney = listAllMoney.Distinct().ToList(); //Get the list of money view model MoneyViewModel moneyToDisplay = null; foreach (Money moneyType in listDistinctMoney) { moneyToDisplay = new MoneyViewModel(); moneyToDisplay.Number = listAllMoney.Where(item => item == moneyType).Count(); moneyToDisplay.DisplayMoney = moneyType; listMoneyToDisplay.Add(moneyToDisplay); } //If there is no money to display return explicit message to the client if (listMoneyToDisplay.Count == 0) { throw new Exception("No money to return"); } } catch (Exception e) { //TODO Log exception Response.StatusCode = (int)HttpStatusCode.InternalServerError; } return(Json(new { displayAmount = amount, listMoney = listMoneyToDisplay }, JsonRequestBehavior.AllowGet)); }
public ActionResult Create() { var citizen = SessionHelper.LoggedCitizen; var country = citizen.Region.Country; var countryPolicies = country.CountryPolicy; var countryMoney = country.Currency; var configuration = ConfigurationHelper.Configuration; if (citizen.PartyMember != null) { return(YouAreAlreadyMemberOfThePartyRedirection()); } var countryFee = new MoneyViewModel(countryMoney, countryPolicies.PartyFoundingFee); var adminFee = new MoneyViewModel(GameHelper.Gold, configuration.PartyFoundingFee); CreatePartyViewModel vm = new CreatePartyViewModel(adminFee, countryFee); return(View(vm)); }
public CountrySummaryViewModel(Entities.Country country) : base(SessionHelper.Session) { CountryID = country.ID; var entity = country.Entity; CountryName = entity.Name; Avatar = Images.GetCountryFlag(CountryName).VM; AdminMoney = new MoneyViewModel(entity.Wallet.GetMoney(CurrencyTypeEnum.Gold, Persistent.Currencies.GetAll())); CountryMoney = new MoneyViewModel(entity.Wallet.GetMoney(country.CurrencyID, Persistent.Currencies.GetAll())); var foreignMoney = entity.Wallet.WalletMoneys .Where(wm => wm.CurrencyID != country.CurrencyID && wm.CurrencyID != (int)CurrencyTypeEnum.Gold && wm.Amount > 0) .OrderByDescending(wm => wm.Amount) .Take(3); foreach (var money in foreignMoney) { ForeignMoney.Add(new MoneyViewModel(Persistent.Currencies.First(c => c.ID == money.CurrencyID), money.Amount)); } }
public ActionResult Account(MoneyViewModel data) { if (!ModelState.IsValid) { return(View(data)); } var accountBook = new AccountBook { Id = Guid.NewGuid(), Categoryyy = data.category, Amounttt = data.money, Dateee = data.date, Remarkkk = data.remark }; db.AccountBook.Add(accountBook); db.SaveChanges(); return(View()); }
public ConstructCompanyViewModel(Entities.Country country, IRegionRepository regionRepository, IWalletService walletService, ICountryTreasureService countryTreasuryService) { Info = new CountryInfoViewModel(country); CountryID = country.ID; var regions = regionRepository.Where(r => r.CountryID == country.ID). Select(r => new { Name = r.Name, ID = r.ID }).ToList(); Regions = CreateSelectList(regions, r => r.Name, r => r.ID, true); Functions = ProductTypeEnumUtils.GetFunctionsList(); GoldNeeded = new MoneyViewModel(GameHelper.Gold, ConfigurationHelper.Configuration.CompanyCountryFee); var walletID = Persistent.Countries.GetById(country.ID).Entity.WalletID; TreasureGold = new MoneyViewModel(walletService.GetWalletMoney(walletID, GameHelper.Gold.ID)); CanSeeTreasury = countryTreasuryService.CanSeeCountryTreasure(country, SessionHelper.CurrentEntity).isSuccess; }
public ViewCompanyViewModel(Company company, IProductRepository productRepository, ICompanyService companyService, CompanyRights companyRights, IRegionService regionService, IRegionRepository regionRepository) { IProductService productService = DependencyResolver.Current.GetService <IProductService>(); Info = new CompanyInfoViewModel(company); Quality = company.Quality; Money = MoneyViewModel.GetMoney(company.Entity.Wallet); ShowEmployeeStats = true; Queue = (double)company.Queue; Rights = companyRights; initializeEmployees(company, companyService); initializeRequiredProducts(company, productRepository, productService); initializeProducedStock(company, productRepository); if (Rights.HaveAnyRights) { Statistics = new CompanyStatisticsViewModel(company, companyService, regionService, regionRepository); } }
public ActionResult Index(MoneyViewModel my) { try { if (ModelState.IsValid) { AccountBook account = new AccountBook(); account.Id = Guid.NewGuid(); account.Categoryyy = my.SelectedTypes; account.Amounttt = my.Money; account.Dateee = my.Date; account.Remarkkk = my.Note; db.AccountBook.Add(account); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception ex) { ex.ToString(); } return(View(my)); }