public PromoIndexModel(AccountBase accountBase, Guid businessId) { this.AccountBase = accountBase; this.BusinessId = businessId; Setup(); }
public void SignIn(AccountBase account, bool createPersistentCookie) { if (createPersistentCookie) { HttpContext.Current.Response.Cookies["FirstName"].Value = account.FirstName; HttpContext.Current.Response.Cookies["FirstName"].Expires = DateTime.Now.AddDays(7); HttpContext.Current.Response.Cookies["Username"].Value = account.Username; HttpContext.Current.Response.Cookies["Username"].Expires = DateTime.Now.AddDays(7); } else { HttpContext.Current.Response.Cookies["FirstName"].Expires = DateTime.Now.AddYears(-30); HttpContext.Current.Response.Cookies["Username"].Expires = DateTime.Now.AddYears(-30); } account.DateLastLoggedIn = DateTime.Now; _dataContext.Save(account); HttpContext.Current.Session["Authenticated"] = true; System.Web.HttpCookie authcookie = FormsAuthentication.GetAuthCookie(account.Username, false); //authcookie.Domain = ConfigSettings.Current.Domain; HttpContext.Current.Response.AppendCookie(authcookie); FormsAuthentication.SetAuthCookie(account.Username, false); EventManager.Raise(new UserLoggedInEvent(new UserLoggedInEvent.EventArgs { UserID = account.ID, UserName = account.Username })); }
/// <summary> /// withdrawal the given account into the account named /// </summary> /// <param name="accountName"></param> /// <param name="amount"></param> public void Withdrawal(string accountName, decimal amount) { AccountBase acc = FindAccount(accountName); // for withdrawal, subtract amount acc.AddTransaction(-1 * amount); }
/// <summary> /// Клиент пробует подключиться /// </summary> void communicator_OnBind(object source, BindEventArgs e) { SmppBindResp pdu = new SmppBindResp(); pdu.SequenceNumber = e.BindPdu.SequenceNumber; if (!communicator.IsBinded) { //Биндинг соединения AccountBase account = null; try { account = billingprov.GetAccount(e.BindPdu.SystemId, e.BindPdu.Password); billing = new BillingProcessor(account); pdu.CommandStatus = (uint)SmppCommandStatus.ESME_ROK; e.IsBindSucessfull = true; LoggerService.Logger.TraceEvent(TraceEventType.Information, LoggingCatoegory.Protocol.IntValue(), string.Format("Client {0} binded", e.BindPdu.SystemId)); PerformanceCountersService.GetCounter(CONNECTION_COUNTER_NAME).Increment(); } catch (Exception ex) { LoggerService.Logger.TraceEvent(TraceEventType.Error, LoggingCatoegory.Protocol.IntValue(), string.Format("Bind failed in fact of account for user {0} cannot be get. Error {1}", e.BindPdu.SystemId, ex.ToString())); pdu.CommandStatus = (uint)SmppCommandStatus.ESME_RBINDFAIL; e.IsBindSucessfull = false; } } else { pdu.CommandStatus = (uint)SmppCommandStatus.ESME_RALYBND; e.IsBindSucessfull = false; } communicator.SendPdu(pdu); }
public void Deposit(string accountName, decimal amount) // deposit the given account into the account named { AccountBase acc = FindAccount(accountName); acc.AddTransaction(amount); }
public void CreateAccount(string accountName, AccountType accountType) // create a new account { AccountBase newAccount = AccountBase.CreateAccount(accountType); accountsDictionary.Add(accountName, newAccount); }
public decimal GetAccountBalance(string accountName) // find the balance of the given account { AccountBase acc = FindAccount(accountName); return(acc.Balance); }
public void Withdrawal(string accountName, decimal amount) // withdrawal the given account into the account named { AccountBase acc = FindAccount(accountName); acc.AddTransaction(-amount); }
/// <summary>Creates service definition that can be registered with a server</summary> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static grpc::ServerServiceDefinition BindService(AccountBase serviceImpl) { return(grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_Login, serviceImpl.Login) .AddMethod(__Method_CreateAccount, serviceImpl.CreateAccount) .AddMethod(__Method_RemoveAccount, serviceImpl.RemoveAccount).Build()); }
private void btnRegister_Click(object sender, EventArgs e) { string username = txtUsername.Text; string password = txtPassword.Text; string password2 = txtPassword2.Text; Int32.TryParse(txtStaffId.Text, out var staffId); //validate all the registration inputs bool allInputsValid = ValidateInputs(username, password, password2, staffId); if (allInputsValid) { //if all inputs are validated, send the registration data to the database and add our new account var ad = new AccountsData(); var account = new AccountBase(username, password, staffId); ad.AddAccount(account); Dispose(); Login.Show(); //user message to let them know their registration was successful var message = new UserMessage(); message.Show("Your account has been successfully created!"); } }
/// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static void BindService(grpc::ServiceBinderBase serviceBinder, AccountBase serviceImpl) { serviceBinder.AddMethod(__Method_CreateAccount, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Kin.Agora.Account.V4.CreateAccountRequest, global::Kin.Agora.Account.V4.CreateAccountResponse>(serviceImpl.CreateAccount)); serviceBinder.AddMethod(__Method_GetAccountInfo, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Kin.Agora.Account.V4.GetAccountInfoRequest, global::Kin.Agora.Account.V4.GetAccountInfoResponse>(serviceImpl.GetAccountInfo)); serviceBinder.AddMethod(__Method_ResolveTokenAccounts, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Kin.Agora.Account.V4.ResolveTokenAccountsRequest, global::Kin.Agora.Account.V4.ResolveTokenAccountsResponse>(serviceImpl.ResolveTokenAccounts)); serviceBinder.AddMethod(__Method_GetEvents, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod <global::Kin.Agora.Account.V4.GetEventsRequest, global::Kin.Agora.Account.V4.Events>(serviceImpl.GetEvents)); }
public BusinessIndexModel(AccountBase accountBase, int pageCount, int currentPage) { this.AccountBase = accountBase; this.pageCount = pageCount; this.currentPage = currentPage; Setup(); }
public void setAccountInfo() { AccountBase account = (AccountBase)Init.Datas["account"]; string name = account.name; int winCount = account.winCount; int loseCount = account.loseCount; int countSum = winCount + loseCount; double winRate; if (countSum == 0) { winRate = Math.Round(100.00, 2); } else { winRate = Math.Round(100.00 * winCount / countSum, 2); } Debug.LogFormat("name:{0},winCount:{1},loseCount:{2},winRate:{3}", name, winCount, loseCount, winRate); Transform namePanel = accountInfoPanel.Find("Name"); namePanel.GetComponent <Text>().text = name; Transform winCountPanel = accountInfoPanel.Find("WinCount"); winCountPanel.GetComponent <Text>().text = "胜利" + winCount; Transform loseCountPanel = accountInfoPanel.Find("LoseCount"); loseCountPanel.GetComponent <Text>().text = "失败" + loseCount; Transform winRatePanel = accountInfoPanel.Find("WinRate"); winRatePanel.GetComponent <Text>().text = "胜率" + winRate + "%"; }
public int GetRewardPoints(string accountName) // find the reward points of the given account { AccountBase acc = FindAccount(accountName); return(acc.RewardPoints); }
public IHttpActionResult adviserMakeInsuranceTransactions(InsuranceTransactionModel model) { // edisRepo.AdviserMakeBondsTransactions(model); AccountBase account = null; if (model.account.accountCatagory == AccountCatergories.GroupAccount.ToString()) { account = edisRepo.GetGroupAccountById(model.account.id); } else { account = edisRepo.GetClientAccountById(model.account.id); } account.MakeTransactionSync(new InsuranceTransactionCreation() { AmountInsured = Convert.ToDouble(model.insuranceAmount), EntitiesInsured = model.insuredEntity, ExpiryDate = model.expiryDate, GrantedOn = model.grantedDate, InsuranceType = model.insuranceType, NameOfPolicy = model.insuranceType.ToString(), PolicyType = model.policyType, Premium = Convert.ToDouble(model.premium), IsAcquire = model.isAquired, Issuer = model.issuer, PolicyAddress = model.policyAddress, PolicyNumber = model.policyNumber }); return(Ok()); }
public void Withdrawal(string accountName, decimal amount) // withdrawal the given account into the account named { AccountBase acc = FindAccount(accountName); //find the account acc.AddTransaction(amount * -1); //subtract the amount from the account balance }
public void DeleteOneClient(Guid id) { AccountBase client = _context.AccountBase.Where(i => i.AccountId == id).FirstOrDefault(); _context.AccountBase.Remove(client); _context.SaveChanges(); }
private void saveBtn_Click(object sender, EventArgs e) { decimal startingAmount = 0; if (!decimal.TryParse(balanceTb.Text, out startingAmount)) { balanceTb.Text = 0.ToString(); MessageBox.Show("Invalid amount!"); return; } DateTime startingDate = startingDateDtp.Value.Date; string name = nameTb.Text; AccountBase account = null; string type = typeCb.SelectedItem.ToString(); switch (type) { case "CheckingAccount": account = new CheckingAccount(name, startingAmount, startingDate); break; case "CreditCard": account = new CreditCard(name, startingAmount, startingDate); break; } NewAccountAddedEventArgs args = new NewAccountAddedEventArgs(); args.NewAccount = account; OnNewAccountAdded(args); this.Close(); }
public async Task <IActionResult> PutAccount(int id, AccountBase account) { if (id != account.Id) { return(BadRequest()); } var e = _context.Account.Find(id); e.Role = account.Role; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Withdrawal(string accountName, decimal amount) // withdrawal the given account into the account named { //takes account name and adds transaction: parameters are multiplied by -1 for that it is subtracted from account AccountBase acc = FindAccount(accountName); acc.AddTransaction(amount * -1); }
public BusinessModel(AccountBase accountBase, Guid id = new Guid(), Role role = Role.BusinessAdmin, String message = null) { this.AccountBase = accountBase; this.BusinessId = id; this.Message = message; Setup(); }
/// <summary>Creates service definition that can be registered with a server</summary> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static grpc::ServerServiceDefinition BindService(AccountBase serviceImpl) { return(grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_CreateAccount, serviceImpl.CreateAccount) .AddMethod(__Method_GetAccountInfo, serviceImpl.GetAccountInfo) .AddMethod(__Method_ResolveTokenAccounts, serviceImpl.ResolveTokenAccounts) .AddMethod(__Method_GetEvents, serviceImpl.GetEvents).Build()); }
private void SaveData() { try { if (Request.QueryString["id"] != null) { int id = int.Parse(Request.QueryString["id"].ToString()); int code = -1; string msg = ""; AccountManager accountManager = new AccountManager(); AccountBase account = new AccountBase(); account.AccountId = id; account.AccountTypeId = int.Parse(ddlAccountType.SelectedValue); account.AccountName = txtAccountName.Text.Trim(); account.AccountShortName = txtAccountShortName.Text.Trim(); account.AccountLevelId = int.Parse(ddlAccountLevel.SelectedValue); account.ContactName = txtContactName.Text.Trim(); account.Address = txtAddress.Text.Trim(); account.PhoneNumber1 = txtPhoneNumber1.Text.Trim(); account.PhoneNumber2 = txtPhoneNumber2.Text.Trim(); account.PhoneNumber3 = txtPhoneNumber3.Text.Trim(); account.Email = txtEmail.Text.Trim(); account.Website = txtWebsite.Text.Trim(); account.Note = txtNote.Text.Trim(); account.AccountStatus = int.Parse(ddlAccountStatus.SelectedValue); account.UpdateDate = DateTime.Now; account.UpdateUser = User.Identity.Name; accountManager.Account_Update(account, ref code, ref msg); if (code == 0) { ErrorBox.Message = string.Empty; NotifyBox.Message = "Lưu dữ liệu thành công"; } else { ErrorBox.Message = "Lưu dữ liệu thất bại"; NotifyBox.Message = string.Empty; } SaveActionLog("Cập nhật", string.Format("code: {0}; msg: {1}; id: {2}", code, msg, id)); } else { ErrorBox.Message = "Không lấy được dữ liệu"; NotifyBox.Message = string.Empty; } } catch (Exception ex) { ErrorBox.Message = "Lỗi chức năng"; NotifyBox.Message = string.Empty; SaveErrorLog(ex); } }
public PromoIndexModel(BusinessLogic.AccountBase accountBase, Guid?businessId, string businessName) { // TODO: Complete member initialization this.AccountBase = accountBase; this.BusinessId = businessId; this.BusinessName = businessName; Setup(); }
public void Withdrawal(string accountName, decimal amount) // withdrawal the given account into the account named { // throw new NotImplementedException(); AccountBase acc = FindAccount(accountName); decimal withdrawalAmount = -(amount); acc.AddTransaction(withdrawalAmount); }
public void UpdateOneClient(ClientVM clientVM) { Guid clientGuid = Guid.Parse(clientVM.ClientId); AccountBase client = _context.AccountBase.Where(i => i.AccountId == clientGuid).FirstOrDefault(); client.Name = clientVM.ClientName; _context.SaveChanges(); }
public void CreateAccountSetsBalanceToZero() { // Arrange AccountBase testAccount = AccountBase.CreateAccount(AccountType.Silver); // Act decimal balance = testAccount.Balance; // Assert Assert.AreEqual(balance, 0.00M); }
public void AddExpenses(AccountBase account, decimal amount) { if (amount > account.Amount) { Console.WriteLine("Insufficient funds."); return; } account.Withdraw(amount); Console.WriteLine("{0}: {1}", account.GetType().Name, account.Amount); }
public void Withdrawal(string accountName, decimal amount) // withdrawal the given account into the account named { // User Story: As a account holder I want to make withdrawals so that my reward balance does not get negatively effected. AccountBase acc = FindAccount(accountName); // I added an if statement in AccountBase.AddTransaction so that // negative amounts won't effect reward points acc.AddTransaction(0 - amount); }
public void DepositToAccountBalance() { // Arrange AccountBase testAccount = AccountBase.CreateAccount(AccountType.Silver); // Act testAccount.AddTransaction(+123.45M); decimal balance = testAccount.Balance; // Assert Assert.AreEqual(balance, +123.45M); }
public void NewAccount(AccountBase account) { }