public HomeController() { var contextName = "FinancialManagerModel"; IFinancialDataSource source = new EntityDataSource(contextName); _service = new FinancialService(source); }
private FinancialService CreateFinancialService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new FinancialService(userId); return(service); }
// GET: Financial public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new FinancialService(userId); var model = service.GetFinancials(); return(View(model)); }
public void GenerateDataParameterless_DoesNotCallDispose() { var repo = new Mock <IRepository <FinancialTarget> >(); FinancialService service = new FinancialService(repo.Object); service.GenerateData(); repo.Verify(x => x.Dispose(), Times.Never); }
public void GenerateData_SatisfiesDisposablePattern() { FinancialService service = new FinancialService(); var repo = DisposablePattern.For(new Mock <IRepository <FinancialTarget> >().Object); service.GenerateData(() => repo.Object); repo.VerifyDisposed(); }
public void DeleteFinancialService() { account = unit.FinancialServiceRepository.FindBy(f => f.Id == 11, includeProperties: "Transactions").FirstOrDefault(); unit.FinancialServiceRepository.Delete(account); unit.Commit(); // Save changes in context Assert.IsNull(unit.FinancialServiceRepository.FindBy(f => f.Id == 11).FirstOrDefault()); }
public void GenerateDataOfRepoFactory_SaveCalled() { var repo = new Mock <IRepository <FinancialTarget> >(); FinancialService service = new FinancialService(repo.Object); service.GenerateData(() => repo.Object); repo.Verify(r => r.Save(), Times.AtLeastOnce()); }
public void GenerateData_CallsDispose() { FinancialService service = new FinancialService(); var repo = new Mock <IRepository <FinancialTarget> >(); service.GenerateData(() => repo.Object); repo.Verify(x => x.Dispose(), Times.AtLeastOnce); }
public async Task Build(FinancialService _service) { _financialService = _service; User = (User)await _service.GetUserByEmail("*****@*****.**"); Group = (Group)await _service.GetGroupById(User.GroupId); BankAccounts = (List <BankAccount>) await _service.GetBankAccountsByUserId(User.Id); Budgets = (List <Budget>) await _service.GetBudgetsByGroupId(Group.Id); }
public void CreateFinancialService() { account = new Tdc { Name = "Cuenta CDT", City = "Valledupar", Number = "0001", Balance = 0 }; unit.FinancialServiceRepository.Add(account); Assert.IsTrue(unit.Commit() > 0); }
private void button1_Click(object sender, EventArgs e) { FinancialService financialService = new FinancialService(); financialDataGridView.DataSource = financialService.GetFinancial(from_dateTimePicker.Text, to_dateTimePicker.Text); double sum = 0; for (int i = 0; i <= financialDataGridView.Rows.Count - 1; i++) { sum = sum + double.Parse(financialDataGridView.Rows[i].Cells[2].Value.ToString()); } totalSellLabel.Text += " " + sum.ToString(); }
public void UpdateFinancialService() { account = unit.FinancialServiceRepository.FindBy(f => f.Id == 11, includeProperties: "Transactions").FirstOrDefault(); account.Income(new Transaction { Amount = 100000, City = "San Sebastian", }); unit.FinancialServiceRepository.Edit(account); // Set State.Modified to account unit.Commit(); // Save changes in context Assert.AreEqual(account.Balance, unit.FinancialServiceRepository.FindBy(f => f.Name == "CDT").FirstOrDefault().Balance); }
public void GenerateDataOfRepoFactory_AddsNothingAfterSave() { var repo = new Mock <IRepository <FinancialTarget> >(); bool saveCalled = false; bool addCalledAfterSave = false; repo.Setup(r => r.Save()).Callback(() => saveCalled = true); repo.Setup(r => r.Add(It.IsAny <FinancialTarget>())).Callback(() => addCalledAfterSave = saveCalled); FinancialService service = new FinancialService(repo.Object); service.GenerateData(() => repo.Object); Assert.False(addCalledAfterSave); }
public static void Main(string[] args) { Console.WriteLine("Showcasing OOP's ceremonies"); Console.WriteLine("Input the initial amount:"); double initialAmount = Convert.ToDouble(Console.ReadLine()); Console.WriteLine(); Console.WriteLine("Input interest rate"); double interestRate = Double.Parse(Console.ReadLine()); FinancialService financialService = new FinancialService(); double interest = financialService.computeInterest(interestRate, initialAmount); double newAmount = financialService.computeNewAmount(interestRate, initialAmount); Console.WriteLine("The generate interest is: " + interest); Console.WriteLine("The new amount is: " + newAmount); Console.ReadKey(); }
public ResponseModel <GetUserInfoResponseModel> GetUserInfo([FromQuery] GetUserInfoRequestModel request) { var user = _repository.GetUserById(request.Id); if (user == null) { return(ResponseManager <GetUserInfoResponseModel> .CreateResponse(400, new string[] { "user not found" }, null)); } var response = new GetUserInfoResponseModel(); response.Name = user; var financialService = new FinancialService(); response.Savings = financialService.GetPensionSavingsForUser(request.Id); response.Id = request.Id; return(ResponseManager <GetUserInfoResponseModel> .CreateResponse(200, null, response)); }
public CreateFinancialServiceResponse Ejecutar(CreateFinancialServiceRequest request) { FinancialService cuenta = _unitOfWork.FinancialServiceRepository.FindFirstOrDefault(t => t.Number == request.Number); if (cuenta != null) { return new CreateFinancialServiceResponse() { Message = "El número de cuenta ya existe." } } ; try { FinancialService newAccount = _factory.CreateEntity(request.AccountType); newAccount.Name = request.Name; newAccount.Number = request.Number; newAccount.City = request.City; _unitOfWork.FinancialServiceRepository.Add(newAccount); _unitOfWork.Commit(); return(new CreateFinancialServiceResponse() { Message = $"Se creo con exito la cuenta {newAccount.Number}." }); } catch (System.Exception ex) { return(new CreateFinancialServiceResponse() { Message = ex.Message }); } } }
private static void Main(string[] args) { string[] wayBillNumbers = File.ReadAllLines("wayBillNumbers.txt"); LMS_DbContext lmsDbContext = new LMS_DbContext(); FinancialService financialService = new FinancialService(null, null, null, null, null, new CustomerRepository(lmsDbContext), new WayBillInfoRepository(lmsDbContext), new WaybillPackageDetailRepository(lmsDbContext), null, null, null); File.AppendAllText("Success.csv", string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}\r\n", "运单号", "实际重量", "结算重量", "总费用", "运费", "挂号费", "燃油费", "附加费", "关税预付服务费")); wayBillNumbers.ToList().ForEach(p => { if (string.IsNullOrWhiteSpace(p)) { return; } Console.WriteLine("开始计算运单{0}结算重量", p); var priceProviderResult = financialService.GetPriceProviderResult(p); if (priceProviderResult == null) { Console.WriteLine("运单{0}无法计算,检查配置", p); File.AppendAllText("Fail.txt", string.Format("{0}\t{1}\r\n", p, "检查配置")); return; } if (priceProviderResult.CanShipping) { Console.WriteLine("运单{0}结算重量:{1}", p, priceProviderResult.Weight); decimal Weight = 0; priceProviderResult.PackageDetails.ForEach(pp => { Weight += pp.Weight + pp.SettleWeight; }); string sql = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}\r\n", p, Weight, priceProviderResult.Weight, priceProviderResult.Value, priceProviderResult.ShippingFee, priceProviderResult.RegistrationFee, priceProviderResult.FuelFee, priceProviderResult.Value - (priceProviderResult.ShippingFee + priceProviderResult.FuelFee + priceProviderResult.RegistrationFee + priceProviderResult.TariffPrepayFee), priceProviderResult.TariffPrepayFee); //string sql = string.Format("update dbo.WayBillInfos set SettleWeight={0} where WayBillNumber='{1}'\r\n", priceProviderResult.Weight, p); File.AppendAllText("Success.csv", sql); } else { Console.WriteLine("运单{0}无法运送:{1}", p, priceProviderResult.Message); File.AppendAllText("Fail.txt", string.Format("{0}\t{1}\r\n", p, priceProviderResult.Message)); } }); Console.WriteLine("处理完成,请查看文件"); Console.ReadKey(); }
public FinancialController() { service = new(); }