public void FromModel() { var model = new Models.Account { AccountTypeName = "Asset" }; var account = model.Map<HomeTrack.Account>(); account.Type.Should().Be(AccountType.Asset); }
public void AddAccount(DateTime time, bool receiptOrPay, string type, double money, string remark, string id = "") { Account toAdd = new Models.Account(time, receiptOrPay, type, money, remark, id); //加入一条账目 accounts.Add(toAdd); //按照时间的降序排序 accounts.Sort(delegate(Account x, Account y) { return(y.time.Date.CompareTo(x.time.Date)); }); }
protected void Page_Load(object sender, EventArgs e) { if (Session["account"] != null) { Models.AccountEntity accEntity = new Models.AccountEntity(); string email = Session["account"].ToString(); Models.Account account = accEntity.FindByEmail(email); if (account == null || account.ACCChucNang > 1) { Response.Redirect("~/"); } else if (this.Page.RouteData.Values["nhanvien"] != null) { try { _nhanvienID = Convert.ToInt32(this.Page.RouteData.Values["nhanvien"]); Models.NhanVienEntity nhanvienEntity = new Models.NhanVienEntity(); Models.NhanVien nhanvien = nhanvienEntity.Find_NhanVien(_nhanvienID); if (nhanvien == null) { Response.Redirect("~/NhanSu"); } else { pnlExtraInforamtion.Visible = true; CUDForm.NhanVienID = _nhanvienID; LVRadGrid.NhanVienID = _nhanvienID; CTXHRadGrid.NhanVienID = _nhanvienID; DTRadGrid.NhanVienID = _nhanvienID; QHRadGrid.NhanVienID = _nhanvienID; TDNNRadGrid.NhanVienID = _nhanvienID; TDTHRadGrid.NhanVienID = _nhanvienID; PTDHRadGrid.NhanVienID = _nhanvienID; KTRadGrid.NhanVienID = _nhanvienID; KLRadGrid.NhanVienID = _nhanvienID; DGRadGrid.NhanVienID = _nhanvienID; CSRadGrid.NhanVienID = _nhanvienID; KKRadGrid.NhanVienID = _nhanvienID; DGLDRadGrid.NhanVienID = _nhanvienID; DGVCRadGrid.NhanVienID = _nhanvienID; } } catch (Exception) { Response.Redirect("~/NhanSu"); } } } else { Response.Redirect("~/"); } }
private void SetupAccount() { _account1 = _fixture.Build <Models.Account>().With(x => x.AccountLegalEntityId, 1).Create(); var accounts = new List <Models.Account>() { _account1 }; _context.Accounts.AddRange(accounts); _context.SaveChanges(); }
public object InsertAccount(Models.Account acc) { var id = acc.Id.ToLower(); if (Collection.Contains(id)) { return(null); } acc.Password = MD5Hash(id + id); Collection.Insert(id, acc); return(id); }
public IActionResult Put([FromBody] Models.Account account) { Models.Account result = _accountRepository.UpdateAccount(account); if (result != null) { return(Accepted(result)); } else { return(StatusCode(500)); } }
private void CheckPerMission() { try { Models.Account account = App.accountController.Account; if (account.Admin.HasValue && (account.Admin.Value != 3 && account.Admin.Value != 1)) { lpInfoProduct.IsEnabled = false; lpNewOrder.IsEnabled = false; } } catch { } }
public ActionResult busquedafilter(String producto_nombre) { Account user = new Models.Account(); string v = Session["valor"].ToString(); var busqueda = db.RECEPCION.Where(r => r.CLIENTES.USUARIO == v); if (!String.IsNullOrEmpty(producto_nombre)) { busqueda = busqueda.Where(r => r.PRODUCTO.Contains(producto_nombre)); } return(View(busqueda.ToList())); }
public ActionResult Detail(int?id) { if (!id.HasValue) { if (Session["UserID"] != null) { id = int.Parse(Session["UserID"].ToString()); } } Models.Account acc = db.Accounts.Find(id); return(View(acc)); }
public IActionResult Post([FromBody] Models.Account account) { var result = _accountRepository.CreateAccount(account); if (result > 0) { return(StatusCode(201, result)); } else { return(StatusCode(500)); } }
public Account GetAccountByName(string name) { Account account = null; using (MySqlConnection conn = new MySqlConnection(connStr)) { MySqlCommand cmd = new MySqlCommand( "select * from Accounts where Name=@Name" , conn ); cmd.Parameters.AddWithValue("@Name", name); try { conn.Open(); } catch { return(account); } try { MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { account = new Models.Account() { Name = reader["Name"].ToString(), Password = reader["Password"].ToString(), DisplayName = reader["DisplayName"].ToString(), Description = reader["Description"].ToString(), Email = reader["Email"].ToString(), GitHub = reader["GitHub"].ToString(), WeiBo = reader["WeiBo"].ToString() }; } } else { return(account); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(account); } } return(account); }
public void AccountService_BlockMoney_Succesfull() { var accountDataBase = new Moq.Mock <IDataBase <Models.AccountDetail> >(); var operationDataBase = new Moq.Mock <IDataBase <Operation> >(); var AccountService = new AccountService(accountDataBase.Object, operationDataBase.Object); var serviceId = Guid.NewGuid(); Guid accountId = Guid.NewGuid(); var origin = new Models.Account(); var accountDetail = new Models.AccountDetail() { Id = accountId, Account = origin, Balance = new Money() { Total = 1000, Currency = "BRL" } }; var ammount = new Models.Money() { Total = 1000, Currency = "BRL" }; accountDataBase .Setup(a => a.GetById(accountId)) .Returns(accountDetail); operationDataBase .Setup(a => a.Create(Moq.It.Is <Operation>(o => o.AccountId == accountId && o.Ammount.Currency == ammount.Currency && o.Ammount.Total == ammount.Total && o.OperationType == OperationType.Out && o.Status == OperationStatus.Waiting && o.TransactionId == Guid.Empty ))) .Returns <Operation>((operation) => { operation.Id = serviceId; return(operation); }); var transactionId = AccountService.BlockAmmount(accountId, ammount); Assert.Equal(serviceId, transactionId); accountDataBase.Verify(a => a.GetById(accountId), Moq.Times.Once); accountDataBase.Verify(a => a.Update(Moq.It.Is <AccountDetail>(ad => ad.Balance.Total == 0)), Moq.Times.Once); operationDataBase.Verify(a => a.Create(Moq.It.IsAny <Operation>()), Moq.Times.Once); }
//更新账目 public void UpdateAccount(DateTime time, bool receiptOrPay, string type, double money, string remark) { if (selectedAccount != null) { selectedAccount.time = time; selectedAccount.receiptOrPay = receiptOrPay; selectedAccount.type = type; selectedAccount.money = money; selectedAccount.remark = remark; //sql更新账目信息 BookViewModel.Instance.UpdateItem(selectedAccount); } selectedAccount = null; }
protected void Page_Load(object sender, EventArgs e) { if (!_quanly) { Models.AccountEntity accEntity = new Models.AccountEntity(); string email = Session["account"].ToString(); _loginACC = accEntity.FindByEmail(email); } if (this.Page.IsPostBack) { _dgEntity.Load_AllDanhGiaOfNhanVien_ToRadGrid(rgDGDV, _nhanvienID); } }
/// <summary> /// Async Process /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> public override System.Threading.Tasks.Task <System.Net.Http.HttpResponseMessage> ExecuteAsync(System.Threading.CancellationToken cancellationToken) { using (Gale.Db.DataService svc = new Gale.Db.DataService("PA_MOT_OBT_Perfl")) { svc.Parameters.Add("USUA_Token", this.Model); Gale.Db.EntityRepository rep = this.ExecuteQuery(svc); Models.Account account = rep.GetModel <Models.Account>().FirstOrDefault(); List <Models.Role> roles = rep.GetModel <Models.Role>(1); Models.SocialProfile counter = rep.GetModel <Models.SocialProfile>(2).FirstOrDefault(); Models.PersonalData personal = rep.GetModel <Models.PersonalData>(3).FirstOrDefault(); Models.Sport sport = rep.GetModel <Models.Sport>(3).FirstOrDefault(); List <Models.EmergencyPhones> phones = rep.GetModel <Models.EmergencyPhones>(4); List <Models.Medal> medals = rep.GetModel <Models.Medal>(5); //---------------------------------------------------------------------------------------------------- //Guard Exception's Gale.Exception.RestException.Guard(() => account == null, "ACCOUNT_DONT_EXISTS", API.Errors.ResourceManager); //---------------------------------------------------------------------------------------------------- account.photo = (account.photo == System.Guid.Empty ? null : account.photo); if (personal != null) { personal.emergencyPhones = (from t in phones select t.phone).ToList(); } //---------------------------------------------------------------------------------------------------- //Create Response var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = new ObjectContent <Object>( new { account = account, roles = roles, sport = sport, personal = personal, social = counter, medals = medals }, System.Web.Http.GlobalConfiguration.Configuration.Formatters.KqlFormatter() ) }; //Return Task return(Task.FromResult(response)); //---------------------------------------------------------------------------------------------------- } }
private void dgvLoans_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { Models.Loan loan = API.Controllers.Loans.FindById(dgvLoans[0, e.RowIndex].Value); Models.Account account = null; if (loan != null) { account = API.Controllers.Accounts.FetchByAccountNumber(loan.Account.Number); } Models.SimpleInterest si = new Models.SimpleInterest((decimal)loan.Principal, (decimal)loan.Rate, loan.Time, (decimal)loan.StandingCharge); si.Calculate(); SimpleInterestLoan sil = new SimpleInterestLoan(account, loan, si); sil.ShowDialog(); }
private static LegalEntityDto MapLegalEntityDto(Models.Account model) { return(new LegalEntityDto { AccountId = model.Id, AccountLegalEntityId = model.AccountLegalEntityId, HasSignedIncentivesTerms = model.HasSignedIncentivesTerms, SignedAgreementVersion = model.SignedAgreementVersion, LegalEntityName = model.LegalEntityName, VrfVendorId = model.VrfVendorId, VrfCaseStatus = model.VrfCaseStatus, HashedLegalEntityId = model.HashedLegalEntityId }); }
protected void Page_Load(object sender, EventArgs e) { if (!_quanly) { string email = Session["account"].ToString(); Models.AccountEntity accEntity = new Models.AccountEntity(); _loginACC = accEntity.FindByEmail(email); } if (!this.Page.IsPostBack) { _tinhocEntity.Load_AllTrinhDoTinHocOfNhanVien_ToRadGrid(rgTrinhDoTinHoc, _nhanvienID); } }
public void UpdateAccount(Account selectedAccount, DateTime time, bool receiptOrPay, string type, double money, string remark) { //移出该条账目 accounts.Remove(selectedAccount); Account toAdd = new Models.Account(time, receiptOrPay, type, money, remark); //加入更新后的账目 accounts.Add(toAdd); //排序 accounts.Sort(delegate(Account x, Account y) { return(y.time.Date.CompareTo(x.time.Date)); }); }
protected void Page_Load(object sender, EventArgs e) { if (!_quanly) { string email = Session["account"].ToString(); Models.AccountEntity accEntity = new Models.AccountEntity(); _loginACC = accEntity.FindByEmail(email); } if (!IsPostBack) { _qtdtEntity.Load_DataSource_RadGrid(RadGridQuaTrinhDaoTao, _nhanvienID); } }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl ??= Url.Content("~/"); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { var userNameComparison = await _context.Accounts.Where(a => a.UserName == Input.UserName).SingleOrDefaultAsync(); if (userNameComparison != null) { ModelState.AddModelError(string.Empty, "User name already taken. Please select a different one"); return(Page()); } var user = new ApplicationUser { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { await _userManager.AddToRoleAsync(user, "User"); _logger.LogInformation("User created a new account with password."); Models.Account account = new Models.Account() { ApplicationUserId = user.Id, UserName = Input.UserName, Theme = "science", Font = "arial", Message = "Welcome to my page!" }; await _context.AddAsync(account); await _context.SaveChangesAsync(); await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
private async Task <DialogTurnResult> CompleteDialog(WaterfallStepContext stepContext, CancellationToken cancellationToken) { dynamic value = (stepContext.Result as Activity).Value; var info = new Models.Account() { Name = value.name, Email = value.email, Phone = value.phone, }; _client.UpdateUserContactInfo(info); await _responder.ReplyWith(stepContext.Context, AccountResponses.ResponseIds.NewInfoSavedPrompt); return(await stepContext.EndDialogAsync()); }
public async Task <ActionResult <ICollection <CompleteAdDTO> > > GetMyAds(UserIdentifiedDTO userIdentifiedDTO) { string username = userIdentifiedDTO.Username; string authTokenString = userIdentifiedDTO.AuthToken; Models.Account accountToFind = await _adService.GetUser(username, authTokenString); if (accountToFind == null) { return(StatusCode(StatusCodes.Status401Unauthorized)); } return(await _smallPostersContext.Ads.Include(a => a.Category).Include(a => a.Creator) .Where(a => a.CreatorId == accountToFind.Id).Select(a => new CompleteAdDTO(a)).ToListAsync()); }
public async Task <IActionResult> Post([FromBody] Models.Account Account) { var profile = await accountRepository.Profiles .SingleOrDefaultAsync(x => x.ProfileID == Account.ProfileID); if (profile == null) { return(BadRequest($"Cannot add account to Profile ({Account.ProfileID}). Profile is in an invalid state.")); } accountRepository.Accounts.Add(Account); await accountRepository.SaveChangesAsync(); return(Created("{id:guid}", Account)); }
public ActionResult Login(Models.Account userr, string returnURL) { if (IsValid(userr.Username, userr.Password)) { FormsAuthentication.SetAuthCookie(userr.Username, false); return(RedirectToLocal(returnURL)); } else { // If we got this far, something failed, redisplay form ModelState.AddModelError(String.Empty, "The user name or password provided is incorrect."); return(View(userr)); } }
private static LegalEntityDto MapLegalEntityDto(Models.Account model) { return(new LegalEntityDto { AccountId = model.Id, AccountLegalEntityId = model.AccountLegalEntityId, LegalEntityId = model.LegalEntityId, LegalEntityName = model.LegalEntityName, VrfVendorId = model.VrfVendorId, VrfCaseStatus = model.VrfCaseStatus, HashedLegalEntityId = model.HashedLegalEntityId, IsAgreementSigned = model.SignedAgreementVersion.HasValue && model.SignedAgreementVersion >= Phase2Incentive.MinimumAgreementVersion(), BankDetailsRequired = MapBankDetailsRequired(model.VrfCaseStatus, model.VrfVendorId) }); }
static RemoteRepositoryModel CreateRemoteRepositoryModel(Repository repository) { var ownerAccount = new Models.Account(repository.Owner); var parent = repository.Parent != null?CreateRemoteRepositoryModel(repository.Parent) : null; var model = new RemoteRepositoryModel(repository.Id, repository.Name, repository.CloneUrl, repository.Private, repository.Fork, ownerAccount, parent, repository.DefaultBranch); if (parent != null) { parent.DefaultBranch.DisplayName = parent.DefaultBranch.Id; } return(model); }
public JsonResult Change(Models.Account user) { Authorize(); bool res = false; string msg = ""; if (string.IsNullOrEmpty(user.Pass) || string.IsNullOrEmpty(user.NewPass)) { msg = "您输入的密码不能为空!"; goto Last; } if (user.Name != user.NewPass) //借助Name传递密码1 { msg = "两次输入的密码不一致!"; goto Last; } if (user.NewPass.Length < 6) { msg = "新密码过于简单!"; goto Last; } DBHelper db = new DBHelper(); string sql = "SELECT Pass FROM Account WHERE Name='" + Session["login_name"].ToString() + "'"; string pass = db.GetFirst(sql); if (user.Pass != pass) { msg = "您输入的登录密码有误!"; goto Last; } string upPass = "******" + user.NewPass + "' WHERE Name='" + Session["login_name"].ToString() + "'"; if (db.GetLine(upPass) == 1) { res = true; msg = "恭喜您,密码修改成功!"; } else { res = false; msg = "系统异常,修改失败!"; } Last : return(Json(new { result = res, message = msg })); }
public async Task Then_payment_paid_date_is_updated_for_correct_payments() { // Arrange var accountLegalEntityId = _fixture.Create <long>(); var account = new Models.Account { AccountLegalEntityId = accountLegalEntityId, VrfVendorId = _fixture.Create <string>() }; var payments = _fixture .Build <Payment>() .Without(p => p.PaidDate) .CreateMany(5).ToList(); foreach (var payment in payments) { payment.AccountLegalEntityId = accountLegalEntityId; } await _dbContext.AddAsync(account); await _dbContext.AddRangeAsync(payments); await _dbContext.SaveChangesAsync(); var paymentIds = payments.Take(4).Select(p => p.Id).ToList(); var expected = _fixture.Create <DateTime>(); // Act await _sut.RecordPaymentsSent(paymentIds, accountLegalEntityId, expected); // Assert var matching = _dbContext.Payments.Where(p => paymentIds.Contains(p.Id)); matching.Count().Should().Be(4); foreach (var payment in matching) { payment.PaidDate.Should().Be(expected); } var nonMatching = _dbContext.Payments.Where(p => !paymentIds.Contains(p.Id)); nonMatching.Count().Should().Be(1); foreach (var payment in nonMatching) { payment.PaidDate.Should().BeNull(); } }
public async Task Then_clawback_send_date_is_updated_for_correct_clawbacks() { // Arrange var accountLegalEntityId = _fixture.Create <long>(); var account = new Models.Account { AccountLegalEntityId = accountLegalEntityId, VrfVendorId = _fixture.Create <string>() }; var clawbacks = _fixture .Build <ClawbackPayment>() .Without(p => p.DateClawbackSent) .CreateMany(5).ToList(); foreach (var clawback in clawbacks) { clawback.AccountLegalEntityId = accountLegalEntityId; } await _dbContext.AddAsync(account); await _dbContext.AddRangeAsync(clawbacks); await _dbContext.SaveChangesAsync(); var clawbacksIds = clawbacks.Take(4).Select(p => p.Id).ToList(); var expected = _fixture.Create <DateTime>(); // Act await _sut.RecordClawbacksSent(clawbacksIds, accountLegalEntityId, expected); // Assert var matching = _dbContext.ClawbackPayments.Where(p => clawbacksIds.Contains(p.Id)); matching.Count().Should().Be(4); foreach (var clawback in matching) { clawback.DateClawbackSent.Should().Be(expected); } var nonMatching = _dbContext.ClawbackPayments.Where(p => !clawbacksIds.Contains(p.Id)); nonMatching.Count().Should().Be(1); foreach (var clawback in nonMatching) { clawback.DateClawbackSent.Should().BeNull(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["account"] != null) { Models.AccountEntity accEntity = new Models.AccountEntity(); string email = Session["account"].ToString(); Models.Account account = accEntity.FindByEmail(email); if (account == null || account.ACCChucNang > 1) { Response.Redirect("~/"); } else if (this.Page.RouteData.Values["phongtangdanhhieu"] != null) { try { int danhhieuID = Convert.ToInt32(this.Page.RouteData.Values["phongtangdanhhieu"]); Models.PhongTangDanhHieuEntity dhEntity = new Models.PhongTangDanhHieuEntity(); Models.PhongTangDanhHieu danhhieu = dhEntity.Find(danhhieuID); if (danhhieu == null) { this.RedirectToIndex(); } } catch { this.RedirectToIndex(); } } else if (this.Page.RouteData.Values["nhanvien"] != null) { int nhanvienID = Convert.ToInt32(this.Page.RouteData.Values["nhanvien"]); Models.NhanVienEntity nvEntity = new Models.NhanVienEntity(); Models.NhanVien nhanvien = nvEntity.Find_NhanVien(nhanvienID); if (nhanvien == null) { this.RedirectToIndex(); } } else { this.RedirectToIndex(); } } else { Response.Redirect("~/"); } }
protected void btnSave_OnClick(object sender, EventArgs e) { using (var ctx = new ApplicationDbContext()) { var account = new Models.Account() { Id = Guid.NewGuid(), AccountName = txtAccountName.Text.Trim(), AccountCategory = (AccountCategory)Convert.ToInt32(ddlAccountCategory.SelectedValue) }; ctx.Accounts.Add(account); ctx.SaveChanges(); lblMessage.Text = $"Account {account.AccountName} created successfully"; } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (CheckLastPageForward(typeof(AddNewAccount))) //Переход с AddNewAccount via Forward { //NothingTODO } else if (CheckLastPage(typeof (AddNewAccount))) { var backStack = Frame.BackStack; var backStackCount = backStack.Count; if (backStackCount > 1) { backStack.RemoveAt(backStackCount - 1); backStack.RemoveAt(backStackCount - 2); } var vm = DataContext as AccountPageViewModel; vm.TestItems.Clear(); var readDataa = await ReadWrite.readStringFromLocalFile("data"); Profile profile = JsonSerilizer.ToProfile(readDataa); DataProfile = profile; if (profile == null) { } else { vm.TestItems.Clear(); foreach (var item in profile.Accounts) { vm.TestItems.Add(item); } } } else if (CheckLastPage(typeof(AddNewHistory))) { var backStack = Frame.BackStack; var backStackCount = backStack.Count; if (backStackCount > 1) { backStack.RemoveAt(backStackCount - 1); backStack.RemoveAt(backStackCount - 2); } var vm = DataContext as AccountPageViewModel; vm.TestItems.Clear(); var readDataa = await ReadWrite.readStringFromLocalFile("data"); Profile CurrentProfilea = JsonSerilizer.ToProfile(readDataa); DataProfile = CurrentProfilea; string limits = ""; var category = DataProfile.Accounts[_lastSelectedItem.Idacc].Categories; if (category.Telephone.isShow) { if (category.Telephone.Amount >= category.Telephone.Limit * 0.95) { limits += category.Telephone.name + " "; category.Telephone.isShow = false; } } if (category.Transport.isShow) { if (category.Transport.Amount >= category.Transport.Limit * 0.95) { limits += category.Transport.name + " " ; category.Transport.isShow = false; } } if (category.Food.isShow) { if (category.Food.Amount >= category.Food.Limit * 0.95) { limits += category.Food.name + " "; category.Food.isShow = false; } } if (category.Entertaiment.isShow) { if (category.Entertaiment.Amount >= category.Entertaiment.Limit * 0.95) { limits += category.Entertaiment.name + " "; category.Entertaiment.isShow = false; } } if (category.Internet.isShow) { if (category.Internet.Amount >= category.Internet.Limit * 0.95) { limits += category.Internet.name + " "; category.Internet.isShow = false; } } if (category.Everything.isShow) { if (category.Everything.Amount >= category.Everything.Limit * 0.95) { limits += category.Everything.name + " "; category.Everything.isShow = false; } } if (limits != "") { ContentDialog dialogo = new ContentDialog(); dialogo.Title = "Вы превысили лимит на следующие категории:"+" " + limits; dialogo.PrimaryButtonText = "Ок"; await dialogo.ShowAsync(); } foreach (var item in CurrentProfilea.Accounts) { vm.TestItems.Add(item); } if (e.Parameter != null) { // Parameter is item ID var id = (int)e.Parameter; var readData = await ReadWrite.readStringFromLocalFile("data"); Profile CurrentProfile = JsonSerilizer.ToProfile(readData); foreach (var sub in CurrentProfile.Accounts) { if (sub.Idacc == id) { _lastSelectedItem = sub; } } } } else if (CheckLastPageForward(typeof(AddNewHistory))) { var backStack = Frame.BackStack; var backStackCount = backStack.Count; if (backStackCount > 1) { backStack.RemoveAt(backStackCount - 1); backStack.RemoveAt(backStackCount - 2); } var vm = DataContext as AccountPageViewModel; vm.TestItems.Clear(); var readDataa = await ReadWrite.readStringFromLocalFile("data"); Profile CurrentProfilea = JsonSerilizer.ToProfile(readDataa); DataProfile = CurrentProfilea; foreach (var item in CurrentProfilea.Accounts) { vm.TestItems.Add(item); } if (e.Parameter != null) { // Parameter is item ID var id = (int)e.Parameter; var readData = await ReadWrite.readStringFromLocalFile("data"); Profile CurrentProfile = JsonSerilizer.ToProfile(readData); foreach (var sub in CurrentProfile.Accounts) { if (sub.Idacc == id) { _lastSelectedItem = sub; } } } } else { var readDataa = await ReadWrite.readStringFromLocalFile("data"); Profile CurrentProfilea = JsonSerilizer.ToProfile(readDataa); var vm = DataContext as AccountPageViewModel; vm.TestItems.Clear(); DataProfile = CurrentProfilea; foreach (var item in CurrentProfilea.Accounts) { vm.TestItems.Add(item); } if (e.Parameter != null) { // Parameter is item ID var id = (int)e.Parameter; var readData = await ReadWrite.readStringFromLocalFile("data"); Profile CurrentProfile = JsonSerilizer.ToProfile(readData); foreach (var sub in CurrentProfile.Accounts) { if (sub.Idacc == id) { _lastSelectedItem = sub; } } } UpdateForVisualState(AdaptiveStates.CurrentState); // Don't play a content transition for first item load. // Sometimes, this content will be animated as part of the page transition. DisableContentTransitions(); } }
private async void New_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { Models.Account del = new Models.Account(); del = _lastSelectedItem; DataProfile.Accounts.Remove(del); await ReadWrite.saveStringToLocalFile("data", JsonSerilizer.ToJson(DataProfile)); this.Frame.Navigate( typeof(AccountPage), _lastSelectedItem.Idacc, new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo()); }
private void ToHistory_Click(object sender, ItemClickEventArgs e) { var clickedItem = e.ClickedItem as Models.Account; _lastSelectedItem = clickedItem; DetailListView.ItemsSource = clickedItem.Histories; if (AdaptiveStates.CurrentState == NarrowState) { // Use "drill in" transition for navigating from master list to detail view Frame.Navigate(typeof(HistoryPage), clickedItem.Idacc, new DrillInNavigationTransitionInfo()); } else { // Play a refresh animation when the user switches detail items. EnableContentTransitions(); } //var clickedItem = e.ClickedItem as Models.Account; //DataToProvide data = new DataToProvide(); //data.id = clickedItem.Idacc; //data.MyProfile = DataProfile; //this.Frame.Navigate( // typeof(HistoryPage), data, // new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo()); }
private async void NewAccount(object sender, RoutedEventArgs e) { Profile profile = new Profile(); if (DataProfile != null) { profile = DataProfile; } double accStart; Models.Account acc = new Models.Account(); acc.Name = accname.Text; if (String.IsNullOrEmpty(accname.Text)) { Error("Введите название аккаунта"); accname.Focus(FocusState.Keyboard); } else if (accname.Text.Length > 19) { Error("Введите название не длинее 20-ти символов"); } else { if (!Double.TryParse(accbalance.Text, out accStart)) { Error("Введите текущий баланс"); accbalance.Text = ""; } else if (Convert.ToDouble(accbalance.Text) > 1000000000000) { Error("Слишком большое число"); accbalance.Text = ""; } else if (Convert.ToDouble(accbalance.Text) < 0) { Error("Введите положительный текущий баланс"); accbalance.Text = ""; } else { double balance = Convert.ToDouble(accbalance.Text); acc.start = balance; if (profile.Accounts.Count == 0) { acc.Idacc = 0; } else { acc.Idacc = profile.Accounts.Count; } acc.Histories = new ObservableCollection<History>(); profile.Accounts.Add(acc); await ReadWrite.saveStringToLocalFile("data", JsonSerilizer.ToJson(profile)); if (profile.Password == null) { this.Frame.Navigate( typeof(NewPassword), new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo()); } else { this.Frame.Navigate( typeof(AccountPage), new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo()); } } } }
private void ToHistory_Click(object sender, ItemClickEventArgs e) { var clickedItem = e.ClickedItem as Models.Account; _lastSelectedItem = clickedItem; Frame.Navigate(typeof(NewLimit), _lastSelectedItem, new DrillInNavigationTransitionInfo()); }
public ActionResult Add() { var model = new Models.Account(); return View(model); }