protected virtual bool Equals(Credit other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.Id, Id) || (Equals(other.Role, Role) && Equals(other.Name, Name)); }
public void Update(Credit credit) { credit.Username = this._username; db.Credits.Attach(credit); db.Entry(credit).State = EntityState.Modified; db.SaveChanges(); }
public Game1() { graphics = new GraphicsDeviceManager(this); gsm = new GamestateManager(); //graphics.IsFullScreen = true; graphics.PreferredBackBufferHeight = 500; graphics.PreferredBackBufferWidth = 900; Content.RootDirectory = "Content"; ExitGame = this; ch = new ControlHandler(); r = new Random(); p = new Player(ch); scores = new Highscores(); intro = new AsteroidsIntro(); credit = new Credit(); screenHeight = graphics.PreferredBackBufferHeight; screenWidth = graphics.PreferredBackBufferWidth; drawShield = false; intersected = false; randomized = false; shield = new Classes.Perks.ShieldPerk(Content, p); speedUp = new Classes.Perks.SpeedUpPerk(Content, p); extraLife = new Classes.Perks.ExtraLifePerk(Content, p); machineGun = new Classes.Perks.MachineGunPerk(Content, p); hud = new HUD(screenWidth, screenHeight, shield); pickUp = new Pickup(); numOfAsteroids = 3; currentGameState = 1; }
public void Compute_For_Less_Than_A_Months() { Credit credit = new Credit(40000, 7.57, 0); decimal payment = credit.GetPaymentForMonth(0); Assert.AreEqual(40000, (double)Decimal.Round(payment, 2)); }
public void Compute_For_Zero_Credit() { Credit credit = new Credit(0, 7.57, 240); decimal payment = credit.GetPaymentForMonth(51); Assert.AreEqual(0, (double)Decimal.Round(payment, 2)); }
public void Compute_For_Zero_Interest() { Credit credit = new Credit(40000, 0, 240); decimal payment = credit.GetPaymentForMonth(51); Assert.AreEqual(166.67, (double)Decimal.Round(payment, 2)); }
public void CreateCredit(Credit credit) { using (var context = new FinanceEntities()) { context.Credit.Add(credit); context.SaveChanges(); } }
public void Compute_For_3rd_Month_Of_4th_Year() { Credit credit = new Credit(40000, 7.57, 240); decimal payment = credit.GetPaymentForMonth(51); Assert.AreEqual(366.43, (double)Decimal.Round(payment, 2)); }
public void Delete(Credit credit) { if (db.Entry(credit).State == EntityState.Detached) { db.Credits.Attach(credit); } db.Credits.Remove(credit); db.SaveChanges(); }
Credit[] generateCredits (params string[] creditNames) { Credit[] credits = new Credit[creditNames.Length]; for (int i = 0; i < credits.Length; i++) { credits[i] = new Credit(creditNames[i]); } return credits; }
public void UpdateCredit(Credit credit) { using (var context = new FinanceEntities()) { context.Credit.Attach(credit); context.Entry(credit).State = EntityState.Modified; context.SaveChanges(); } }
public PenyaThread(int i, Credit obj) { _number = i; var thread = new Thread(Process) { IsBackground = true }; thread.Start(obj); }
public ActionResult Create(Credit credit) { ICreditRepository repository = new EFCreditRepository(User.Identity.Name); if (ModelState.IsValid) { repository.Insert(credit); return RedirectToAction("Index"); } return View(credit); }
public void getSubsProfile(string MSISDN, int acctId, out string subsType, out int tarifId, out string tarifLabel, out string subsStatus, out Credit creditInfo, out int rc, out string msg) { subsType = null; tarifId = 0; tarifLabel = null; subsStatus = null; creditInfo = null; msg = null; rc = 0; }
public InvoiceLine(int invoice_line_id, int invoice_id, int patient_id, int offering_id, int credit_id, decimal quantity, decimal price, decimal tax, string area_treated, string service_reference, int offering_order_id) { this.invoice_line_id = invoice_line_id; this.invoice_id = invoice_id; this.patient = new Patient(patient_id); this.offering = offering_id == -1 ? null : new Offering(offering_id); this.credit = credit_id == -1 ? null : new Credit(credit_id); this.quantity = quantity; this.price = price; this.tax = tax; this.area_treated = area_treated; this.service_reference = service_reference; this.offering_order = offering_order_id == -1 ? null : new OfferingOrder(offering_order_id); }
public void testOrderNoOverCredit() { Customer merchant = createPersonCustomer(); Order order = merchant.CreateOrder(null); BankAccount ba = createBankAccount(); ba.AssociateToCustomer(merchant); BankAccount buyerBA = createBankAccount(); BankAccountVerification verification = buyerBA.Verify(); verification.Confirm(1, 1); Dictionary <string, object> debitPayload = new Dictionary <string, object>(); debitPayload.Add("order", order.href); debitPayload.Add("description", "Debit for Order #234123"); debitPayload.Add("amount", 5000); Debit debit = buyerBA.Debit(debitPayload); order.Reload(); Assert.AreEqual(debit.order.href, order.href); Assert.AreEqual(5000, debit.amount); Assert.AreEqual(5000, order.amount); Assert.AreEqual(5000, order.amount_escrowed); Dictionary <string, object> creditPayload = new Dictionary <string, object>(); creditPayload.Add("order", order.href); creditPayload.Add("description", "Payout for Order #234123"); creditPayload.Add("amount", 6000); Credit credit = null; try { credit = ba.Credit(creditPayload); } catch (APIException e) { Assert.AreEqual(409, e.status_code); } order.Reload(); Assert.AreEqual(5000, order.amount); Assert.AreEqual(5000, order.amount_escrowed); }
public void nextbtn() { index++; if (index == 1) { WajahRatri(); chat = "KAKAK AKU TAKUT SEKALI"; name = "Ratri"; StartCoroutine(ShowText()); enter = false; btn.SetActive(false); } if (index == 2) { WajahRatri(); chat = "MAKHLUK ITU HAMPIR MEMAKANKU"; name = "Ratri"; StartCoroutine(ShowText()); enter = false; btn.SetActive(false); } if (index == 3) { WajahJaka(); chat = "Syukurlah aku tidak terlambat"; name = "Jaka"; StartCoroutine(ShowText()); enter = false; btn.SetActive(false); } if (index == 4) { WajahJaka(); chat = "Mari kita pulang Ratri"; name = "Jaka"; StartCoroutine(ShowText()); enter = false; btn.SetActive(false); } if (index == 5) { Canvas.SetActive(false); Credit.SetActive(true); Invoke("Backtomain", 5); PlayerPrefs.SetFloat("Position", 6.856345f); } }
public static UserDTO DALtoDTO(User user) { UserDTO newUser = new UserDTO() { Id_user = user.UserId, Id = user.UserId, First_name = user.firstName, Last_name = user.lastname, Vip = user.VIP, Friend = user.frirnd, //Status_user = (Status_userE)user.status_User.GetValueOrDefault(), Father_name = user.father_name, Status_reason = user.Status_reason, Scoring = user.Scoring, Remarks = user.remarks, MaritalStatus = user.MaritalStatus, Communication_ways = new Communication(user.phon1, user.phon2, user.email_addres, user.city, user.street, user.num_street), // Bank_Details = new Bank_details(user.bankName, user.brunchName, user.account_number.GetValueOrDefault(), user.Bank_account_owner), Joining_date = (DateTime)user.joining_date, Management_status = Management_statusBL.GetByName(user.NameManagement_status), _Manager = (int)user.Manager_permissions.GetValueOrDefault() }; SuperGmachEntities db = new SuperGmachEntities(); Credit credit = db.Credits.FirstOrDefault(c => c.UserId == user.UserId); if (credit != null) { newUser.Crdit = new Crdit() { CVV = credit.CVV, Number = credit.Number, Token = credit.Token, }; } BankDetails bankDetails = db.BankDetails.FirstOrDefault(b => b.UserId == user.UserId); newUser.Bank_Details = new Bank_details() { Account = bankDetails.Account, Bank = bankDetails.Bank, Brunch = bankDetails.Branch, Owner = bankDetails.owner, UserId = bankDetails.UserId.ToString() }; return(newUser); }
private async Task Transfer(AccountId originAccountId, AccountId destinationAccountId, PositiveMoney transferAmount) { IAccount originAccount = await this._accountRepository .GetAccount(originAccountId) .ConfigureAwait(false); IAccount destinationAccount = await this._accountRepository .GetAccount(destinationAccountId) .ConfigureAwait(false); if (originAccount is Account withdrawAccount && destinationAccount is Account depositAccount) { PositiveMoney localCurrencyAmount = await this._currencyExchange .Convert(transferAmount, withdrawAccount.Currency) .ConfigureAwait(false); Debit debit = this._accountFactory .NewDebit(withdrawAccount, localCurrencyAmount, DateTime.Now); if (withdrawAccount.GetCurrentBalance().Amount - debit.Amount.Amount < 0) { this._outputPort?.OutOfFunds(); return; } await this.Withdraw(withdrawAccount, debit) .ConfigureAwait(false); PositiveMoney destinationCurrencyAmount = await this._currencyExchange .Convert(transferAmount, depositAccount.Currency) .ConfigureAwait(false); Credit credit = this._accountFactory .NewCredit(depositAccount, destinationCurrencyAmount, DateTime.Now); await this.Deposit(depositAccount, credit) .ConfigureAwait(false); this._outputPort?.Ok(withdrawAccount, debit, depositAccount, credit); return; } this._outputPort?.NotFound(); }
public Output(ICustomer customer, IAccount account, string token) { List <Transaction> transactionResults = new List <Transaction>(); foreach (ICredit credit in account.GetCredits()) { Credit creditEntity = (Credit)credit; Transaction transactionOutput = new Transaction( creditEntity.Description, creditEntity .Amount .ToAmount() .ToDouble(), creditEntity.TransactionDate); transactionResults.Add(transactionOutput); } foreach (IDebit debit in account.GetDebits()) { Debit debitEntity = (Debit)debit; Transaction transactionOutput = new Transaction( debitEntity.Description, debitEntity .Amount .ToAmount() .ToDouble(), debitEntity.TransactionDate); transactionResults.Add(transactionOutput); } Account = new Account( account.Id, account.GetCurrentBalance().ToDouble(), transactionResults); List <Account> accountOutputs = new List <Account>(); accountOutputs.Add(Account); Customer = new Customer(customer, accountOutputs); Token = token; }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Credit credit = db.Credits.Find(id); if (credit == null) { return(HttpNotFound()); } ViewBag.BankAccountID = new SelectList(db.BankAccounts.Where(e => e.Profile.UserName == User.Identity.Name).ToList(), "ID", "Number"); ViewBag.ProfileID = new SelectList(db.Profiles, "ID", "UserName", credit.BankAccount); return(View(credit)); }
public Credit AddNewCredit(Credit credit) { try { using (UnitOfWork.Start()) { credit = Repository<Credit>.Save(credit); UnitOfWork.Current.TransactionalFlush(); } } catch (Exception ex) { return null; } return credit; }
public ActionResult CreditProposalAccept(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CreditProposal cr = db.CreditProposals.Find(id); if (cr == null) { return(HttpNotFound()); } else { Credit credit = new Credit() { BankAccount = cr.BankAccount, Cash = cr.Cash, MoneyToPay = cr.Cash + Decimal.Multiply(cr.Cash, (decimal)0.1), MonthlyRepayment = cr.Cash / cr.NumberOfMonths, NumberOfMonthsLeft = cr.NumberOfMonths, NumberOfMonths = cr.NumberOfMonths, StartDate = DateTime.Now, EndDate = DateTime.Now.AddMonths(cr.NumberOfMonths), Status = CreditStatus.Active }; cr.ProposalStatus = CreditProposalStatus.Approved; db.Credits.Add(credit); cr.BankAccount.Balance += cr.Cash; Transfer transfer = new Transfer() { TransferType = TransferType.Credit, ReceiversName = $"{cr.BankAccount.Profile.Name} {cr.BankAccount.Profile.LastName}", ReceiversNumber = cr.BankAccount.Number, Title = "Credit", Cash = cr.Cash, ReceiverBalance = cr.BankAccount.Balance, Date = DateTime.Now }; db.Transfers.Add(transfer); db.SaveChanges(); Email.SendMail("*****@*****.**", "Credit Proposal Status", "Hello Yours credit proposal was accepted"); } return(RedirectToAction("CreditProposalsList")); }
public void ValiderCredit(Credit credit, CompteClient compteClient, Employe employe) { compteClientBLO = new CompteClientBLO(); operationBLO = new OperationBLO(); Credit oldCredit = credit; if (compteClient != null) { compteClientBLO.CrediterCompteClient(compteClient, credit.MontantEmprunte, employe); } credit.StatutCredit = StatutCredit.Non_remboursé; credit.DateCreditValidation = DateTime.Now; creditBLO[creditBLO.IndexOf(oldCredit)] = credit; operationBLO.AjouterOperation(TypeOperation.Remboursement, employe, credit.Client, new CompteClient("Indefini"), credit.MontantEmprunte, "toto tata"); }
public BaseEntity BuildObject(Dictionary <string, object> row) { var credit = new Credit { Id = GetIntValue(row, DB_COL_ID), Monto = GetDoubleValue(row, DB_COL_MONTO), Tasa = GetDoubleValue(row, DB_COL_TASA), ClienteId = GetStringValue(row, DB_COL_CLIENTEID), Cuota = GetDoubleValue(row, DB_COL_CUOTA), FechaInicio = GetStringValue(row, DB_COL_FEC_INIC), Estado = GetStringValue(row, DB_COL_ESTADO), Saldo = GetDoubleValue(row, DB_COL_SALDO), Moneda = GetStringValue(row, DB_COL_MONEDA) }; return(credit); }
public BaseEntity BuildObject(Dictionary <string, object> row) { var credit = new Credit { CreditId = GetIntValue(row, DB_COL_CREDIT_ID), UserId = GetStringValue(row, DB_COL_USER_ID), Amount = GetIntValue(row, DB_COL_AMOUNT), InterestRate = GetDoubleValue(row, DB_COL_INTEREST_RATE), CreditLine = GetStringValue(row, DB_COL_NAME), Fee = GetDoubleValue(row, DB_COL_FEE), StartDate = GetDateValue(row, DB_COL_START_DATE), Status = Convert.ToChar(GetStringValue(row, DB_COL_STATUS)), Balance = GetDoubleValue(row, DB_COL_BALANCE) }; return(credit); }
public async Task When_AddingCreditToAccount_Then_TheCreditIsReturnedCorrectly() { // arrange var credit = new Credit() { AccountId = AccountId, CreditAmount = Random.Next(100, 200) }; // act var processed = await Client.CreateCredit(credit, true, RequestOptions); // assert Assert.That(processed, Is.Not.Null); Assert.That(processed.AccountId, Is.EqualTo(AccountId)); Assert.That(processed.CreditAmount, Is.InRange(100, 200)); }
public async Task <Credit> Handle(DepositMessage command) { Account account = await accountReadOnlyRepository.Get(command.AccountId); if (account == null) { throw new AccountNotFoundException($"The account {command.AccountId} does not exists or is already closed."); } Credit credit = Credit.Create(Amount.Create(command.Amount)); account.Deposit(credit); await accountWriteOnlyRepository.Update(account); return(credit); }
public ActionResult Index() { if (!(HttpContext.Session.GetString("actions") == "admin" || HttpContext.Session.GetString("actions") == "guest")) { Credit credit = new Credit(); credit.creditSum = 0; credit.creditPeriod = 0; credit.payout = 0; credit.percent = 0; credit.isDiff = false; return(View(credit)); } else { return(RedirectToRoute(new { controller = "Employee", action = "Login" })); } }
public string CourseDatabaseString() { StringBuilder cdbstring = new StringBuilder(Term); cdbstring.Insert(5, Coursename); cdbstring.Insert(17, Coursetitle); cdbstring.Insert(34, Instructor); cdbstring.Insert(46, Credit.ToString()); cdbstring.Insert(52, Seats.ToString()); cdbstring.Insert(57, Times.Count); foreach (coursetime time in Times) { cdbstring.Append(time.ToString() + " "); } return(cdbstring.ToString()); }
public void CannotGetCreditInfoForNotExistingCredit() { //arrange int userId = 10, creditId = 5; Credit mockedCredit = null; _creditRepository.Setup(c => c.GetSingle(It.Is <int>(x => x.Equals(creditId)))).Returns(mockedCredit); var service = InstantiateService(); //act var result = service.GetCreditInfo(userId, creditId); //assert Assert.AreEqual("The credit does not exist or you don't have permission to access it", result.Message); Assert.IsFalse(result.Success); }
public async Task <AssetBalanceModel> GetLykkeBalanceByAssetIdAsync(string assetId) { Balance balance = await _balanceService.GetByAssetIdAsync(ExchangeNames.Lykke, assetId); Credit credit = await _creditService.GetByAssetIdAsync(assetId); decimal balanceAmount = balance?.Amount ?? decimal.Zero; decimal creditAmount = credit?.Amount ?? decimal.Zero; return(new AssetBalanceModel { AssetId = assetId, Amount = balanceAmount, CreditAmount = creditAmount, Disbalance = balanceAmount - creditAmount }); }
// DELETE == public IHttpActionResult Delete(Credit credit) { try { var mng = new CreditManager(); mng.Delete(credit); apiResp = new ApiResponse(); apiResp.Message = "Action was executed."; return(Ok(apiResp)); } catch (BussinessException bex) { return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message))); } }
public static Credit SaveNewCredit() { Credit credit = new Credit(); credit.Name = "test credit"; credit.BankName = "test bank"; credit.StartDate = System.DateTime.Today; credit.FinishDate = System.DateTime.Today.AddDays(30); credit.Amount = 10000; credit.ProvisionPercent = 2; credit.InsurancePercent = 5; credit.YearlyInterestPercent = 18; credit.MinInstallment = 10; Repository<Credit>.SaveOrUpdate(credit); //save return credit; }
public async Task <ActionResult> Create(Credit credit) { try { credit = await Repository.InsertAsync(credit); if (string.IsNullOrEmpty(credit.Id)) { return(RedirectToAction("Index")); } return(RedirectToAction("Edit", new { id = credit.Id })); } catch { return(View()); } }
public void Recharge(Credit credit, int clientId) { credit.Balance = credit.Value; credit.ClientId = clientId; _context.Credit.Add(credit); _context.SaveChanges(); DateTime hoje = new DateTime(); Extract extract = new Extract( ExtractType.RECARGA, credit.Description, hoje, credit.Value, Operation.CREDITO, this.GetTotalBalance(clientId), clientId ); _extractService.Insert(extract); }
// PUT: api/Credit/5 public IHttpActionResult Put(Credit credit) { try { var credMng = new CreditMangement(); credMng.Update(credit); apiResponse.Message = "Credit was updated"; return(Ok(apiResponse)); } catch (BusinessException bex) { return(InternalServerError(new Exception(bex.ExceptionId + "--" + bex.AppMessage.Message))); } }
public async Task <Credit> ProcessCreditWithBankAsync(Credit credit) { var invoice = await _invoiceRepository.GetInvoiceAsync(credit.InvoiceId); var customer = await _customerRepository.GetCustomerAsync(invoice.CustomerId); var bankAccount = await _bankAccountRepository.GetBankAccountAsync(customer.Id, null); credit.CustomerName = $"{customer.Title} {customer.FirstName} {customer.MiddleName} {customer.LastName}"; credit.AccountNo = bankAccount.AccountNo; credit.SortCode = bankAccount.SortCode; credit.HasCreditAgreement = customer.CreditAgreement; SendCreditToBack(credit); return(credit); }
/// <summary> /// Initializes a new instance of the <see cref="RegisterOutput" /> class. /// </summary> /// <param name="externalUserId">External User Id.</param> /// <param name="customer">Customer object.</param> /// <param name="account">Account object.</param> public RegisterOutput(ExternalUserId externalUserId, ICustomer customer, IAccount account) { if (account is Domain.Accounts.Account accountEntity) { List <Transaction> transactionResults = new List <Transaction>(); foreach (ICredit credit in accountEntity.Credits .GetTransactions()) { Credit creditEntity = (Credit)credit; Transaction transactionOutput = new Transaction( Credit.Description, creditEntity.Amount, creditEntity.TransactionDate); transactionResults.Add(transactionOutput); } foreach (IDebit debit in accountEntity.Debits .GetTransactions()) { Debit debitEntity = (Debit)debit; Transaction transactionOutput = new Transaction( Debit.Description, debitEntity.Amount, debitEntity.TransactionDate); transactionResults.Add(transactionOutput); } this.Account = new Account( accountEntity.Id, accountEntity.GetCurrentBalance(), transactionResults); List <Account> accountOutputs = new List <Account>(); accountOutputs.Add(this.Account); this.Customer = new Customer(externalUserId, customer, accountOutputs); } else { throw new ArgumentNullException(nameof(account)); } }
public BaseEntity BuildObject(Dictionary <string, object> row) { var credit = new Credit { CreditId = GetIntValue(row, DB_COL_CREDIT_ID), Amount = GetDoubleValue(row, DB_COL_AMOUNT), Rate = GetDoubleValue(row, DB_COL_RATE), Name = GetStringValue(row, DB_COL_NAME), Fee = GetDoubleValue(row, DB_COL_FEE), StartDate = GetDateValue(row, DB_COL_START_DATE), Status = GetStringValue(row, DB_COL_STATUS), OperationalBalance = GetDoubleValue(row, DB_COL_OPERATIONAL_BALANCE), FK_CUSTOMER_ID = GetStringValue(row, DB_COL_FK_CUSTOMER_ID) }; return(credit); }
public async Task <Transaction> Handle(DepositCommand command) { Account account = await accountReadOnlyRepository.Get(command.AccountId); if (account == null) { throw new AccountNotFoundException($"The account {command.AccountId} does not exists or is already closed."); } Transaction transaction = Credit.Create(command.CustomerId, Amount.Create(command.Amount)); account.Deposit(transaction); await accountWriteOnlyRepository.Update(account); return(transaction); }
public async Task <ActionResult> Delete(int id, Credit credit) { try { await connection.SoftBuild() .From("credit") .Where("id", id) .AsDelete() .SaveUpdateAsync(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public Account(IAccount account) { var accountEntity = (Domain.Accounts.Account)account; AccountId = account.Id; CurrentBalance = account .GetCurrentBalance() .ToDouble(); List <Transaction> transactionResults = new List <Transaction>(); foreach (ICredit credit in accountEntity.Credits .GetTransactions()) { Credit creditEntity = (Credit)credit; Transaction transactionOutput = new Transaction( creditEntity.Description, creditEntity .Amount .ToAmount() .ToDouble(), creditEntity.TransactionDate); transactionResults.Add(transactionOutput); } foreach (IDebit debit in accountEntity.Debits .GetTransactions()) { Debit debitEntity = (Debit)debit; Transaction transactionOutput = new Transaction( debitEntity.Description, debitEntity .Amount .ToAmount() .ToDouble(), debitEntity.TransactionDate); transactionResults.Add(transactionOutput); } Transactions = transactionResults; }
public GetAccountDetailsOutput(IAccount account) { var accountEntity = (Manga.Domain.Accounts.Account)account; AccountId = accountEntity.Id; CurrentBalance = accountEntity .GetCurrentBalance() .ToDecimal(); List <Transaction> transactionResults = new List <Transaction>(); foreach (var credit in accountEntity.Credits .GetTransactions()) { Credit creditEntity = (Credit)credit; Transaction transactionOutput = new Transaction( creditEntity.Description, creditEntity .Amount .ToMoney() .ToDecimal(), creditEntity.TransactionDate); transactionResults.Add(transactionOutput); } foreach (var debit in accountEntity.Debits .GetTransactions()) { Debit debitEntity = (Debit)debit; Transaction transactionOutput = new Transaction( debitEntity.Description, debitEntity .Amount .ToMoney() .ToDecimal(), debitEntity.TransactionDate); transactionResults.Add(transactionOutput); } Transactions = transactionResults; }
private static Credit _AddCredit() { GeneralSettings.GetInstance("").DeleteAllParameters(); GeneralSettings.GetInstance("").AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); GeneralSettings.GetInstance("").AddParameter(OGeneralSettings.USECENTS, true); FundingLineManager _fundingLineManager = new FundingLineManager(DataUtil.TESTDB); FundingLine fund = new FundingLine(); fund.Purpose = "Microsoft financement"; fund.Name = "AFD130"; fund.Deleted = false; fund.StartDate = DateTime.Now; fund.EndDate = DateTime.Now; _fundingLineManager.AddFundingLine(fund, null); Package _package = new Package(); _package.Name = "Package"; _package.Delete = false; _package.LoanType = OLoanTypes.Flat; _package.ClientType = 'G'; _package.ChargeInterestWithinGracePeriod = true; _package.InstallmentType = new DataHelper().AddBiWeeklyInstallmentType(); _package.FundingLine = fund; _package.Id = new ProductManager(DataUtil.TESTDB).AddPackage(_package); User user = new User(); user.Id = new DataHelper().AddUserWithIntermediaryAttributs(); Credit credit = new Credit(_package, 1000, 3, 6, 0, new DateTime(2006, 1, 1), user, GeneralSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisioningTable.GetInstance(user)); credit.CreationDate = DateTime.Today.AddDays(-1); credit.StartDate = DateTime.Today; credit.LoanOfficer = user; credit.CloseDate = DateTime.Today.AddDays(1); credit.BranchCode = "CA"; credit.FundingLine = fund; //new DataHelper().AddGenericFundingLine(); credit.Code = "TEST"; return(credit); }
public Result Delete(Order order) { bool res = Entities.Find(I => I.Id == order.Id && I.CustomerId == order.CustomerId) != null; if (res) { Cash cash = _cashManager.Entities.Find(I => I.OrderId == order.Id); Check check = _checkManager.Entities.Find(I => I.OrderId == order.Id); Credit credit = _creditManager.Entities.Find(I => I.OrderId == order.Id); OrderDetail orderDetail = _orderDetailManager.Entities.Find(I => I.OrderId == order.Id); Customer customer = _customerManager.Entities.Find(I => I.Id == order.CustomerId); if (cash != null) { _cashManager.Delete(cash); } if (check != null) { _checkManager.Delete(check); } if (credit != null) { _creditManager.Delete(credit); } if (orderDetail != null) { _orderDetailManager.Delete(orderDetail); } if (customer != null) { int orderId = customer.OrderIds.Find(I => I == order.Id); if (orderId != 0) { customer.OrderIds.Remove(orderId); _customerManager.Update(customer); } } return(base.Delete(Entities.FindIndex(I => I.Id == order.Id))); } return(new Result { ResultState = ResultState.Erorr }); }
public static Semester ParseTable(Match match) { Semester semester = new Semester(); semester.Name = match.Groups[1].Value; var html = match.Value; //Parse Summary var summaryRegex = new Regex("<th colspan=2 BGCOLOR=99FF99>[^<]+<td colspan=6 align=center>\n([^\n]+)", RegexOptions.Multiline | RegexOptions.IgnoreCase); var summaryMatches = summaryRegex.Matches(html); semester.TotalAverage = TryGetFloat(summaryMatches[0].Groups[1].Value, 0); semester.ConductGrade = TryGetFloat(summaryMatches[1].Groups[1].Value, 0); semester.CreditsWanted = TryGetFloat(summaryMatches[2].Groups[1].Value, 0); semester.CreditsGot = TryGetFloat(summaryMatches[3].Groups[1].Value, 0); //Parse Credits var creditRegex = new Regex( "<tr><th align=Right>([^\\s]*)\\s+" + "<th>([^\\s]*)\\s+" + "<th align=left><a href=\"[^\"]+\">([^<]+)</a>\\s+" + "<th align=center>([^\\s]+)\\s+" + "<th align=center>([^\\s]+)\\s+" + "<th align=right>\\s*([^\\s]+)\\s+" + "<th align=right>\\s*([^\\s]+)\\s+" + "<td>([^\n]+)", RegexOptions.Multiline | RegexOptions.IgnoreCase); var creditMatches = creditRegex.Matches(html); var credits = new List <Credit>(); foreach (Match creditMatch in creditMatches) { Credit credit = new Credit(); credit.CourseId = creditMatch.Groups[1].Value; credit.Type = creditMatch.Groups[2].Value; credit.Name = creditMatch.Groups[3].Value; credit.Credits = TryGetFloat(creditMatch.Groups[6].Value, 0); credit.Grade = TryGetFloat(creditMatch.Groups[7].Value, 0f); credit.Note = creditMatch.Groups[8].Value; credit.Note = new Regex("<[^>]+>").Replace(credit.Note, " ").Trim(); credits.Add(credit); } semester.Credits = credits; return(semester); }
/// <summary> /// Sets the text of the credit /// </summary> /// <param name="myCredit"> The intended credit to be displayed </param> public void setText (Credit myCredit) { myText = transform.GetComponent<Text>(); myChildrenTexts = transform.GetComponentsInChildren<Text>(); if (myCredit.type == Credit.Type.Header || myCredit.type == Credit.Type.Name || myCredit.type == Credit.Type.Role ) { if (myText != null) { myText.text = myCredit.name; } else { #if DEBUG Debug.Log(myText); #endif } } else if (myCredit.type == Credit.Type.NameAndCollege) { myText.text = myCredit.name; myChildrenTexts[1].text = myCredit.college; } else if (myCredit.type == Credit.Type.ThreeName) { for (int i = 0; i < myChildrenTexts.Length; i++) { myChildrenTexts[i].text = myCredit.names[i]; } } }
public Credit(int credit_id, int credit_type_id, int entity_id, decimal amount, decimal amount_used, string voucher_descr, DateTime expiry_date, int voucher_credit_id, int invoice_id, int tyro_payment_pending_id, int added_by, DateTime date_added, int deleted_by, DateTime date_deleted, decimal pre_deleted_amount, int modified_by, DateTime date_modified) { this.credit_id = credit_id; this.credit_type = new IDandDescr(credit_type_id); this.entity_id = entity_id; this.amount = amount; this.amount_used = amount_used; this.voucher_descr = voucher_descr; this.expiry_date = expiry_date; this.voucher_credit = voucher_credit_id == -1 ? null : new Credit(voucher_credit_id); this.invoice_id = invoice_id; this.tyro_payment_pending_id = tyro_payment_pending_id; this.added_by = new Staff(added_by); this.date_added = date_added; this.deleted_by = deleted_by == -1 ? null : new Staff(deleted_by); this.date_deleted = date_deleted; this.pre_deleted_amount = pre_deleted_amount; this.date_modified = date_modified; this.modified_by = modified_by == -1 ? null : new Staff(modified_by); }
public IHttpActionResult ProcessPayment(FormCollection parameters) { //first get the payment processor var paymentMethodName = parameters.Get(PaymentParameterNames.PaymentMethodTypeName); if (string.IsNullOrEmpty(paymentMethodName)) { VerboseReporter.ReportError("Invalid payment method", "process_payment"); return RespondFailure(); } //the transaction amount decimal amount; var amountString = parameters.Get(PaymentParameterNames.Amount) ?? "0"; decimal.TryParse(amountString, out amount); PaymentMethodType methodType; if (System.Enum.TryParse(paymentMethodName, out methodType)) { methodType = PaymentMethodType.CreditCard; } //get the payment processor now var paymentProcessor = _paymentProcessingService.GetPaymentProcessorPlugin(amount, methodType); if (paymentProcessor == null) { VerboseReporter.ReportError("Invalid payment method", "process_payment"); return RespondFailure(); } //convert form collection to dictionary to check if parameters are valid var formCollectionDictionary = parameters.ToDictionary(pair => pair.Key, pair => (object)pair.Value); var isValid = paymentProcessor.AreParametersValid(formCollectionDictionary); UserPaymentMethod paymentMethod = null; if (!isValid) { //the parameters are not valid. but that may also mean that the user is selecting an already saved payment method //and so he wouldn't have sent that data again var savedPaymentMethodIdString = parameters.Get(PaymentParameterNames.UserSavedPaymentMethodId); int savedPaymentMethodId; if (int.TryParse(savedPaymentMethodIdString, out savedPaymentMethodId)) { var userPaymentMethods = _paymentMethodService.Get(x => x.UserId == ApplicationContext.Current.CurrentUser.Id && x.Id == savedPaymentMethodId, null); if (userPaymentMethods.Any()) { paymentMethod = userPaymentMethods.First(); isValid = true; } } //still invalid? something is not right then. if (!isValid) { VerboseReporter.ReportError("Invalid parameters to process payment", "process_payment"); return RespondFailure(); } } //we save the payment method in our database if it's CreditCard if (paymentProcessor.Supports(PaymentMethodType.CreditCard)) { if (paymentMethod == null) { #region saving payment method to database var creditCardNumber = parameters.Get(PaymentParameterNames.CardNumber); //let's validate the card for level 1 check (luhn's test) first before storing var isCardValid = PaymentCardHelper.IsCardNumberValid(creditCardNumber); //card number if (!isCardValid) { VerboseReporter.ReportError("Invalid card number", "process_payment"); return RespondFailure(); } //expiration date var expireMonth = parameters.Get(PaymentParameterNames.ExpireMonth); var expireYear = parameters.Get(PaymentParameterNames.ExpireYear); if (!expireYear.IsInteger() || !expireMonth.IsInteger()) { VerboseReporter.ReportError("Invalid expiration month or year", "process_payment"); return RespondFailure(); } //card issuer var cardIssuer = PaymentCardHelper.GetCardTypeFromNumber(creditCardNumber); if (!cardIssuer.HasValue) { VerboseReporter.ReportError("Unsupported card provider", "process_payment"); return RespondFailure(); } var nameOnCard = parameters.Get(PaymentParameterNames.NameOnCard); //encrypt credit card info to store in db var key = ConfigurationManager.AppSettings.Get("EncryptionKey"); var salt = ConfigurationManager.AppSettings.Get("Salt"); var cardNumber = _cryptographyService.Encrypt(creditCardNumber, key, salt); //encrypt the card info //fine if the card is valid, but is the card number already in our record, then not possible to save the same again if (_paymentMethodService.DoesCardNumberExist(cardNumber)) { VerboseReporter.ReportError("The card number is already saved in records", "process_payment"); return RespondFailure(); } paymentMethod = new UserPaymentMethod() { UserId = ApplicationContext.Current.CurrentUser.Id, IsVerified = false, PaymentMethodType = PaymentMethodType.CreditCard, CardIssuerType = cardIssuer.ToString().ToLowerInvariant(), CardNumber = creditCardNumber, CardNumberMasked = PaymentCardHelper.MaskCardNumber(creditCardNumber), NameOnCard = nameOnCard, }; //save this payment method _paymentMethodService.Insert(paymentMethod); #endregion } } //we need to see if we should only authorize or capture as well //the idea is if it's a sponsorship context, it's better to authorize the payment transaction and capture later when //the sponsorship is accepted //we thought of initially only authorizing sponsorship transactions and capture when it's accepted. //but that flow doesn't seem to work quite well, thoughts? var authorizeOnly = false; // (parameters.Get(PaymentParameterNames.PaymentContext) ?? string.Empty) == "sponsor"; //so we are ready for payment processing, let's create a paymenttrasaction for storing in our db var paymentTransaction = new PaymentTransaction() { IsLocalTransaction = true, PaymentStatus = PaymentStatus.Pending, TransactionAmount = amount, TransactionGuid = Guid.NewGuid(), CreatedOn = DateTime.UtcNow, UserIpAddress = WebHelper.GetClientIpAddress() }; _paymentTransactionService.Insert(paymentTransaction); //now proceed further with the payment //create the transaction request var transactionRequest = new TransactionRequest() { Amount = amount, CurrencyIsoCode = "USD",//TODO: SET CURRENCY AS SELECTED BY USER PaymentProcessorSystemName = paymentProcessor.PluginInfo.SystemName, UserId = ApplicationContext.Current.CurrentUser.Id, Parameters = formCollectionDictionary, TransactionUniqueId = paymentTransaction.TransactionGuid.ToString() }; var response = paymentProcessor.Process(transactionRequest, authorizeOnly); //update values of transaction parameters for future reference paymentTransaction.TransactionCodes = response.ResponseParameters; //update payment transaction _paymentTransactionService.Update(paymentTransaction); if (response.Success) { //let's verify the payment method first if it's not if (paymentMethod != null && !paymentMethod.IsVerified) { paymentMethod.IsVerified = true; _paymentMethodService.Update(paymentMethod); } //now since the response was success, we can actually assign some credits to the user var creditCount = amount * (1 / _paymentSettings.CreditExchangeRate); var credit = new Credit() { PaymentTransactionId = paymentTransaction.Id, CreatedOnUtc = DateTime.UtcNow, CreditCount = creditCount, CreditExchangeRate = _paymentSettings.CreditExchangeRate, //if it's authorize only transaction, we assign the credits, but they won't be usable before they are approved by capture CreditTransactionType = CreditTransactionType.Issued, CreditType = CreditType.Transactional, IsExpired = false }; //save credit _creditService.Insert(credit); //get total available credits of user var usableCreditCount = _creditService.GetUsableCreditsCount(ApplicationContext.Current.CurrentUser.Id); return RespondSuccess(new { UsableCreditCount = usableCreditCount }); } VerboseReporter.ReportError("An error occured while processing payment", "process_payment"); return RespondFailure(); }
private void StartThreadForCreditType(int counter, Credit credit) { new AnnuityСreditThread(counter, credit); }
public static Credit[] GetByEntityID(int entity_id, string credit_type_ids = null, bool inc_deleted = false) { DataTable tbl = GetDataTable_ByEntityID(entity_id, credit_type_ids, inc_deleted); Credit[] list = new Credit[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) list[i] = CreditDB.LoadAll(tbl.Rows[i]); return list; }
public static Credit[] GetByInvoiceID(int invoice_id) { DataTable tbl = GetDataTable_ByInvoiceID(invoice_id); Credit[] list = new Credit[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) list[i] = CreditDB.LoadAll(tbl.Rows[i]); return list; }
public static Credit[] GetByVoucherCreditID(int voucher_entity_id, bool inc_deleted = false) { DataTable tbl = GetDataTable_ByVoucherCreditID(voucher_entity_id, inc_deleted); Credit[] list = new Credit[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) list[i] = CreditDB.LoadAll(tbl.Rows[i]); return list; }
protected string GetVoucherLink(bool isMobileDevice, Credit credit) { string voucherLink = "CreditDetailV2.aspx?ct=1&type=view&id=" + credit.VoucherCredit.CreditID; string voucherOnclick = isMobileDevice ? "open_new_tab('" + voucherLink + "');return false;" : "window.showModalDialog('" + voucherLink + "', 'Show Popup Window', 'dialogWidth:500px;dialogHeight:600px;center:yes;resizable:no; scroll:no;');return false;"; string descr = credit.VoucherCredit == null || credit.VoucherCredit.VoucherDescr == null ? "" : credit.VoucherCredit.VoucherDescr; string descrShortened = descr.Length > 42 ? descr.Substring(0, 40) + ".." : descr; return credit.VoucherCredit == null ? "" : "<a href=\"" + voucherOnclick + "\" onclick=\"" + voucherOnclick + "\">" + descrShortened + "</a> ($" + credit.VoucherCredit.Amount + ")"; }
protected string GetInvoiceLink(bool isMobileDevice, Credit credit) { string invoiceLink = "Invoice_ViewV2.aspx?invoice_id=" + credit.InvoiceID; string invoiceOnclick = isMobileDevice ? "open_new_tab('"+invoiceLink+"');return false;" : "window.showModalDialog('" + invoiceLink + "', 'Show Popup Window', 'dialogWidth:775px;dialogHeight:725px;center:yes;resizable:no; scroll:no;');return false;"; return credit.InvoiceID == -1 ? "" : "<a href=\"" + invoiceLink + "\" onclick=\"" + invoiceOnclick + "\">" + credit.InvoiceID + "</a>"; }
protected void FillCreditGrid(Credit credit) { DataTable tbl = CreditHistoryDB.GetDataTable_ByCreditID(credit.CreditID); for (int i = 0; i < tbl.Rows.Count; i++) { if (Convert.ToInt32(tbl.Rows[i]["credit_history_credit_type_id"]) == 2 || Convert.ToInt32(tbl.Rows[i]["credit_history_credit_type_id"]) == 4) { tbl.Rows[i]["credit_history_amount"] = (-1 * Convert.ToInt32(tbl.Rows[i]["credit_history_amount"])).ToString(); tbl.Rows[i]["credit_history_pre_deleted_amount"] = (-1 * Convert.ToInt32(tbl.Rows[i]["credit_history_pre_deleted_amount"])).ToString(); } } if (credit.CreditType.ID == 1 && tbl.Rows.Count > 0) { show_hide_history_link.Visible = true; GrdCredit.DataSource = tbl; GrdCredit.DataBind(); } }
public static string GetTranslatedCreditType(Credit credit) { switch (credit) { case Credit.Art: return Translation.Art; case Credit.Camera: return Translation.Camera; case Credit.Cast: return Translation.Cast; case Credit.CostumeAndMakeUp: return Translation.CostumeAndMakeUp; case Credit.Crew: return Translation.Crew; case Credit.Directing: return Translation.Directing; case Credit.Production: return Translation.Production; case Credit.Sound: return Translation.Sound; case Credit.Writing: return Translation.Writing; default: return string.Empty; } }
private static List<Credit> LoadCredits(List<Show> shows, List<Person> people) { var maxId = 0; var list = new List<Credit>(); Credit crd; crd = new Credit { CreditId = ++maxId, ShowId = 1, PersonId = 1, CreditTypeId = 1, Character = "Philomena" }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); crd = new Credit { CreditId = ++maxId, ShowId = 1, PersonId = 2, CreditTypeId = 2 }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); crd = new Credit { CreditId = ++maxId, ShowId = 1, PersonId = 3, CreditTypeId = 5 }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); crd = new Credit { CreditId = ++maxId, ShowId = 1, PersonId = 3, CreditTypeId = 1, Character = "Martin Sixsmith" }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); crd = new Credit { CreditId = ++maxId, ShowId = 1, PersonId = 4, CreditTypeId = 1, Character = "Young Philomena" }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); crd = new Credit { CreditId = ++maxId, ShowId = 1, PersonId = 5, CreditTypeId = 2 }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); crd = new Credit { CreditId = ++maxId, ShowId = 2, PersonId = 6, CreditTypeId = 2 }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); crd = new Credit { CreditId = ++maxId, ShowId = 2, PersonId = 6, CreditTypeId = 5 }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); crd = new Credit { CreditId = ++maxId, ShowId = 2, PersonId = 7, CreditTypeId = 1, Character = "Anna" }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); crd = new Credit { CreditId = ++maxId, ShowId = 2, PersonId = 8, CreditTypeId = 1, Character = "Olaf" }; list.Add(crd); FindShowById(shows, crd.ShowId).Credits.Add(crd); FindPersonById(people, crd.PersonId).Credits.Add(crd); return list; }
//reads in the text file and generates a list of credits private void readCSVFile() { //reads in the entire csv string [] allTextAsArray = credits.text.Split('\n'); //splits it into people by line creditees = new Credit[allTextAsArray.Length-1]; int personIndex = 0; //the loop should terminate before creditees.length, so we need a variable to resize the array int endIndex = creditees.Length; bool isGroup = false; //loops through the people and creates a list of credits for (int i = 0; i < creditees.Length; i++) { //exits the loop if we've hit the final credit if (personIndex >= allTextAsArray.Length) { #if DEBUG Debug.Log("Breaking out of the loop here: " + i); #endif endIndex = i; break; } string [] person = Utility.SplitString(allTextAsArray[personIndex], ','); personIndex++; if (isGroup) { if (person[0].Contains("=")) { isGroup = false; } } //if there is only a name if (isGroup) { string person2 = processGroupName(ref personIndex, allTextAsArray, ref isGroup); string person3 = processGroupName(ref personIndex, allTextAsArray, ref isGroup); creditees[i] = new Credit(Credit.Type.ThreeName, person[0], person2, person3); } else if (person.Length == 1) { //if the credit is a header if (person[0].Contains("Header")) { creditees[i] = new Credit(Credit.Type.Header, person[0].Split('=')[1]); } else if (person[0].Contains("Role")) { creditees[i] = new Credit(Credit.Type.Role, person[0].Split('=')[1]); } else if (person[0].Contains("Group")) { creditees[i] = new Credit(Credit.Type.Header, person[0].Split('=')[1]); isGroup = true; }else { creditees[i] = new Credit(Credit.Type.Name, person[0]); } } else if (person.Length == 2) { //if there's a name and a role creditees[i] = new Credit (Credit.Type.NameAndCollege, person[0], person[1]); } //trims the array of credits to the proper length System.Array.Resize(ref creditees, endIndex); } //trims the creditees array // creditees }