public void ItShouldReturnTheTotalAmountOfMoneyReceived() { var spendService = Substitute.For <ISpendService>(); spendService.GetRandomIdea().Returns(new SpendModel { Price = 50 }); var transactionService = Substitute.For <ITransactionService>(); transactionService.GetTransactions().Returns(new List <DailyTransactionBlockViewModel> { new DailyTransactionBlockViewModel { TotalReceived = 40 }, new DailyTransactionBlockViewModel { TotalReceived = 20 } }); var assetService = Substitute.For <IAssetService>(); var sut = new SummaryService(transactionService, spendService, assetService); var actual = sut.GetSummary(); Assert.That(actual.TotalReceived, Is.EqualTo(60)); }
public async Task TestFinancialSummaryEmptyBillsEmptyApartments() { ACMDbContext context = ACMDbContextInMemoryFactory.InitializeContext(); SummaryService summaryService = new SummaryService(context); Spending spending1 = new Spending { Amount = 100, Text = "beer1", IsPayed = true }; Spending spending2 = new Spending { Amount = 200, Text = "beer2", IsPayed = true }; Spending spending3 = new Spending { Amount = 300, Text = "beer3", IsPayed = false }; Spending spending4 = new Spending { Amount = 400, Text = "beer4", IsPayed = false }; await context.Spendings.AddAsync(spending1); await context.Spendings.AddAsync(spending2); await context.Spendings.AddAsync(spending3); await context.Spendings.AddAsync(spending4); await context.SaveChangesAsync(); FinancialSummaryDTO output = summaryService.FinancialSummary(); Assert.Empty(output.GoodHomeowners); Assert.Empty(output.BadHomeowners); Assert.Equal(2, output.PaidSpendings.Count); Assert.Equal(100, output.PaidSpendings[1].Amount); Assert.Equal("beer1", output.PaidSpendings[1].Text); Assert.Equal(200, output.PaidSpendings[0].Amount); Assert.Equal("beer2", output.PaidSpendings[0].Text); Assert.Equal(2, output.UnpaidSpendings.Count); Assert.Equal(300, output.UnpaidSpendings[1].Amount); Assert.Equal("beer3", output.UnpaidSpendings[1].Text); Assert.Equal(400, output.UnpaidSpendings[0].Amount); Assert.Equal("beer4", output.UnpaidSpendings[0].Text); Assert.Equal(0, output.Paid); Assert.Equal(0, output.ToBePaid); Assert.Equal(300, output.Spend); Assert.Equal(700, output.ToBeSpend); Assert.Equal(-1000, output.CurrentBalance); }
private void AddTechnicalMessages(List <RmsReportMonitoringRaw> lRawMessages, List <RMSAttachment> lAttachments = null) { try { using (var db = new MyDbContext()) { db.Configuration.AutoDetectChangesEnabled = false; foreach (var rawMessage in lRawMessages) { db.RmsReportMonitoringRaws.Add(rawMessage); } db.SaveChanges(); } var sv = new SummaryService(); var caller = new SummaryService.DoSummaryMonitoringAsync(sv.DoSummaryMonitoring); caller.BeginInvoke(lRawMessages, lAttachments, null, null); } catch (Exception ex) { throw new RMSWebException(this, "0500", "AddTechnicalMessages failed. " + ex.Message, ex, false); } }
public ActionResult Index() { SummaryService s = new SummaryService(); List <BudgetPlanCategoryDto> budgetCategories = s.GetMonthActivitiesByCategory(DateTime.Now); return(View("SummaryIndex", budgetCategories)); }
public HomeController() { _parsingService = new ParsingService(); _configurationService = new ConfigurationService(); _summaryService = new SummaryService(); _deleteRecordService = new DeleteRecordService(); }
public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = RouteName)] HttpRequestMessage req, TraceWriter log) { log.Info("C# HTTP trigger function processed a request."); var hit = await req.Content.ReadAsAsync <Hit>(); var summaryApiUrl = ConfigurationManager.AppSettings["SummaryApiUrl"]; var summaryApiKey = ConfigurationManager.AppSettings["SummaryApiKey"]; var storageConnectionString = ConfigurationManager.AppSettings["StorageConnectionString"]; var summaryService = new SummaryService(summaryApiUrl, summaryApiKey); var summary = summaryService.GetSummaryForHit(hit); var repo = new ArticleEntityRepo(storageConnectionString); var article = new ArticleEntity(Guid.NewGuid(), hit.Title, hit.Url, summary); repo.SaveArticle(article); await req.InvokeAzureFunction($"TextToSpeech/id/{article.PartitionKey}/title/{article.RowKey}", RouteName); return(req.CreateResponse(HttpStatusCode.OK, summary)); }
private string CheckRecordAdjust(int mana_id, AdjustRecordModel model) { string result = ""; InterfaceSummaryService summary_service = new SummaryService(); List <t_summary> summary_list = new List <t_summary>(); try { summary_list = summary_service.SearchByManagerID(mana_id).ToList(); } catch { } foreach (int id in model.summ_id) { t_summary summary = summary_list.Where(M => M.summ_id == id).FirstOrDefault(); if (summary == null) { result = HtmlExtensions.Lang("_Error_Comm_Para"); } } return(result); }
public ActionResult DeleteSummary(int id = 0) { FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); var json_result = new JsonResult(); InterfaceSummaryService summary_service = new SummaryService(); try { t_summary delete = summary_service.GetByID(id); if (delete != null && delete.mana_id == mana_id) { summary_service.Delete(delete); json_result.Data = new { Result = true, Message = "" }; } else { json_result.Data = new { Result = false, Message = HtmlExtensions.Lang("_Error_Comm_Para") }; } } catch { json_result.Data = new { Result = false, Message = HtmlExtensions.Lang("_Error_Comm_Para") }; } return(json_result); }
public ActionResult SummaryType() { ViewBag.Title = HtmlExtensions.Lang("Financing_SummaryType_Title"); FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); List <t_summary> summary_list = new List <t_summary>(); InterfaceSummaryService summary_service = new SummaryService(); try { summary_list = summary_service.SearchByManagerID(mana_id).ToList(); } catch { } #if login_debug t_summary add1 = new t_summary(); add1.mana_id = 1; add1.summ_desc = "123"; add1.summ_id = 1; summary_list.Add(add1); #endif ViewBag.DATA = JsonConvert.SerializeObject(summary_list); return(View()); }
public DataPointsController() { _context = new ApplicationDbContext(); _parsingService = new ParsingService(); _scatterPlotService = new ScatterPlotService(); _summaryService = new SummaryService(); }
public ActionResult RecordDetail() { ViewBag.Title = HtmlExtensions.Lang("Financing_RecordDetail_Title"); FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); InterfaceRecordTypeService record_type_service = new RecordTypeService(); InterfaceSummaryService summary_service = new SummaryService(); InterfaceSummaryRecordService summary_record_service = new SummaryRecordService(); List <t_record_type> record_type_list = new List <t_record_type>(); List <t_summary> summary_list = new List <t_summary>(); List <t_summary_record> summary_record_list = new List <t_summary_record>(); try { record_type_list = record_type_service.Table().ToList(); summary_list = summary_service.SearchByManagerID(mana_id).ToList(); summary_record_list = summary_record_service.SearchByManagerID(mana_id).ToList(); } catch { } ViewBag.RECORD_TYPE = JsonConvert.SerializeObject(record_type_list); ViewBag.SUMMARY = JsonConvert.SerializeObject(summary_list); ViewBag.SUMMARY_RECORD = CreateRecordDetailCount(summary_list, summary_record_list); return(View()); }
public ActionResult OverallSummary() { SummaryService s = new SummaryService(); UserDto u = s.GetUserOverallSummary(); return(PartialView(u)); }
public static IMapper GetMapper(this SummaryService account) { return((new MapperConfiguration(cfg => { cfg.CreateMap <Document, DocumentDTO>(); cfg.CreateMap <DocumentDTO, Document>(); })).CreateMapper()); }
public MainWindowVm() { _dataService = new DataService(); _refreshingService = new RefreshingService(this); _editorService = new EditorService(_dataService, _refreshingService); _summaryService = new SummaryService(); RefreshCommand.Execute(null); }
public async Task <JsonResult> ReadSummaryKendoGrid([DataSourceRequest] DataSourceRequest request) { SummaryService t = new SummaryService(); var test = await t.Calculate(); var c = Json(test, JsonRequestBehavior.AllowGet); return(c); }
private string CreateShowSummaryRecord(int mana_id, List <t_summary_record> summary_record_list) { List <object> list = new List <object>(); InterfaceRecordTypeService record_type_service = new RecordTypeService(); InterfaceSummaryService summary_service = new SummaryService(); InterfaceLoanTypeService loan_type_service = new LoanTypeService(); List <t_record_type> record_type_list = new List <t_record_type>(); List <t_summary> summary_list = new List <t_summary>(); List <t_loan_type> loan_type_list = new List <t_loan_type>(); try { record_type_list = record_type_service.Table().ToList(); summary_list = summary_service.SearchByManagerID(mana_id).ToList(); loan_type_list = loan_type_service.Table().ToList(); } catch { } foreach (t_summary_record foreach_data in summary_record_list) { t_record_type find_record_type = record_type_list.Where(M => M.reco_code == foreach_data.reco_type_code).FirstOrDefault(); t_summary find_summary = summary_list.Where(M => M.summ_id == foreach_data.summ_id).FirstOrDefault(); //转账处理 t_summary find_tran_summary = null; if (foreach_data.summ_tran_id != 0) { foreach_data.amount = -foreach_data.amount; find_tran_summary = summary_list.Where(M => M.summ_id == foreach_data.summ_tran_id).FirstOrDefault(); } string tran_summary_desc = find_tran_summary == null ? "" : "->" + find_tran_summary.summ_desc; //借贷处理 t_loan_type loan_type = loan_type_list.Where(M => M.loan_code == foreach_data.loan_type_code).FirstOrDefault(); string loan_desc = loan_type == null ? "" : "(" + loan_type.loan_desc + ")"; if (find_record_type != null && find_summary != null) { var insert = new { summary_record_id = foreach_data.summ_reco_id, add_date = foreach_data.add_time.ToString("yyyy-MM-dd HH:mm:ss"), record_type_desc = find_record_type.reco_desc + loan_desc, summary_desc = find_summary.summ_desc + tran_summary_desc, amount = foreach_data.amount, remark = foreach_data.remark, is_deal = foreach_data.is_deal }; list.Add(insert); } } return(JsonConvert.SerializeObject(list)); }
public ActionResult Delete(int activityId, int budgetPlanCategoryId) { ActivityService s = new ActivityService(); s.DeleteActivity(activityId); SummaryService ss = new SummaryService(); return(PartialView("_CategorySummary", ss.GetMonthCategoryActivities(budgetPlanCategoryId, DateTime.Now))); }
public async Task TestFinancialSummaryGoodData() { ACMDbContext context = ACMDbContextInMemoryFactory.InitializeContext(); SummaryService summaryService = new SummaryService(context); Apartment apartment1 = new Apartment { Number = 1 }; Apartment apartment2 = new Apartment { Number = 2 }; Apartment apartment3 = new Apartment { Number = 3 }; Apartment apartment4 = new Apartment { Number = 4 }; Bill bill1 = new Bill { Amount = 10, Apartment = apartment1, IsPayed = true }; Bill bill2 = new Bill { Amount = 20, Apartment = apartment2, IsPayed = true }; Bill bill3 = new Bill { Amount = 30, Apartment = apartment3, IsPayed = false }; Bill bill4 = new Bill { Amount = 40, Apartment = apartment4, IsPayed = false }; Spending spending1 = new Spending{Amount = 100,Text = "beer1",IsPayed = true}; Spending spending2 = new Spending{Amount = 200,Text = "beer2",IsPayed = true}; Spending spending3 = new Spending{Amount = 300,Text = "beer3",IsPayed = false}; Spending spending4 = new Spending{Amount = 400,Text = "beer4",IsPayed = false}; await context.Apartments.AddAsync(apartment1); await context.Apartments.AddAsync(apartment2); await context.Apartments.AddAsync(apartment3); await context.Apartments.AddAsync(apartment4); await context.Bills.AddAsync(bill1); await context.Bills.AddAsync(bill2); await context.Bills.AddAsync(bill3); await context.Bills.AddAsync(bill4); await context.Spendings.AddAsync(spending1); await context.Spendings.AddAsync(spending2); await context.Spendings.AddAsync(spending3); await context.Spendings.AddAsync(spending4); await context.SaveChangesAsync(); FinancialSummaryDTO output = summaryService.FinancialSummary(); Assert.Equal(2, output.GoodHomeowners.Count); Assert.Equal(1, output.GoodHomeowners[0].ApartmentNumber); Assert.Equal(0, output.GoodHomeowners[0].Amount); Assert.Equal(2, output.GoodHomeowners[1].ApartmentNumber); Assert.Equal(0, output.GoodHomeowners[1].Amount); Assert.Equal(2, output.BadHomeowners.Count); Assert.Equal(3, output.BadHomeowners[1].ApartmentNumber); Assert.Equal(30, output.BadHomeowners[1].Amount); Assert.Equal(4, output.BadHomeowners[0].ApartmentNumber); Assert.Equal(40, output.BadHomeowners[0].Amount); Assert.Equal(2, output.PaidSpendings.Count); Assert.Equal(100, output.PaidSpendings[1].Amount); Assert.Equal("beer1", output.PaidSpendings[1].Text); Assert.Equal(200, output.PaidSpendings[0].Amount); Assert.Equal("beer2", output.PaidSpendings[0].Text); Assert.Equal(2, output.UnpaidSpendings.Count); Assert.Equal(300, output.UnpaidSpendings[1].Amount); Assert.Equal("beer3", output.UnpaidSpendings[1].Text); Assert.Equal(400, output.UnpaidSpendings[0].Amount); Assert.Equal("beer4", output.UnpaidSpendings[0].Text); Assert.Equal(30, output.Paid); Assert.Equal(70, output.ToBePaid); Assert.Equal(300, output.Spend); Assert.Equal(700, output.ToBeSpend); Assert.Equal(-900, output.CurrentBalance); }
static Helper() { string databaseName = "FinanceManager"; string schemaName = "dbo"; string[] tableNames = { "Activities", "Categories" }; SummaryService summaryService = new SummaryService(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, databaseName, schemaName, tableNames); CategoryService categoryService = new CategoryService(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, databaseName, schemaName, tableNames[1]); ActivityService activityService = new ActivityService(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, databaseName, schemaName, tableNames); _service = new DataMapper(summaryService, categoryService, activityService); }
public string StartSummaryStatusAllClients() { try { BSL.SummaryService service = new SummaryService(); return(service.DoSummaryStatusAllClients()); } catch (Exception ex) { new RMSWebException(this, "0500", "StartSummaryStatusAllClients failed. " + ex.Message, ex, true); return("Failed: " + ex.Message); } }
public ActionResult UpdateCategory(int activityId, int categoryId) { // need to submit the whole page ActivityService s = new ActivityService(); SummaryService ss = new SummaryService(); ActivityDto a = new ActivityDto { ActivityId = activityId, CategoryId = categoryId }; s.SaveActivityUpdate(a); return(PartialView("SummaryIndex", ss.GetMonthActivitiesByCategory(DateTime.Now))); }
public void AddWebsiteMessage(List <RmsReportMonitoringRaw> lRawMessages) { try { var ip = GetIP(); foreach (var rmsReportMonitoringRaw in lRawMessages) { rmsReportMonitoringRaw.ClientIpAddress = ip; } using (var db = new MyDbContext()) { db.Configuration.AutoDetectChangesEnabled = false; foreach (var rawMessage in lRawMessages) { db.RmsReportMonitoringRaws.Add(rawMessage); } db.SaveChanges(); } List <RmsReportMonitoringRaw> validateList = new List <RmsReportMonitoringRaw>(); foreach (var rawMessage in lRawMessages) { if (string.IsNullOrEmpty(rawMessage.ClientCode)) { continue; } if (string.IsNullOrEmpty(rawMessage.MessageGroupCode)) { continue; } if (string.IsNullOrEmpty(rawMessage.Message)) { continue; } validateList.Add(rawMessage); } var sv = new SummaryService(); var caller = new SummaryService.DoSummaryWebsiteMonitoringAsync(sv.DoSummaryWebsiteMonitoring); caller.BeginInvoke(lRawMessages, null, null); } catch (Exception ex) { new RMSWebException(this, "0500", "AddWebsiteMessage failed. " + ex.Message, ex, true); } }
static void Main(string[] args) { GetCases("india"); CountryService countryService = new CountryService(); var countries = countryService.GetCountries(); StatisticsService statisticsService = new StatisticsService(); var stats = statisticsService.GetStatistics(); SummaryService summaryService = new SummaryService(); var summary = summaryService.GetGlobalSummary(); System.Console.ReadLine(); }
public void ItShouldReturnASummaryModelForUserData() { var userData = new UserData { Transactions = new List <TransactionModel> { new TransactionModel { CreditOrDebit = "Debit", Amount = 2500, Merchant = "tesco", CreatedDate = new DateTime(2016, 10, 30) } } }; var spendService = Substitute.For <ISpendService>(); var transactionService = Substitute.For <ITransactionService>(); transactionService.GetTransactions(userData).Returns(new List <DailyTransactionBlockViewModel> { new DailyTransactionBlockViewModel { Date = "30 October 2016", TotalReceived = 0, TotalSpent = 25, Transactions = new List <TransactionViewModel> { new TransactionViewModel { HasUpgrade = true, ImageUrl = "image url", Name = "tesco", Amount = 25, Type = "Debit" } } } }); var assetService = Substitute.For <IAssetService>(); var sut = new SummaryService(transactionService, spendService, assetService); var actual = sut.GetSummary(userData); Assert.That(actual.Capital, Is.EqualTo(-25)); Assert.That(actual.SpendingSuggestions, Is.Empty); }
public async Task GetSummaryListReturnsNullWhenDataDoesntExist() { // Arrange var repository = A.Fake <ICosmosRepository <SummaryDataModel> >(); A.CallTo(() => repository.GetData( A <Expression <Func <SummaryDataModel, SummaryDataModel> > > .Ignored, A <Expression <Func <SummaryDataModel, bool> > > .Ignored)).Returns((IList <SummaryDataModel>)null); var summaryService = new SummaryService(repository, mapper); // Act var result = await summaryService.GetSummaryList(RequestUrl).ConfigureAwait(false); // Assert Assert.Null(result); }
public ActionResult SummaryType(AddSummaryTypeModel model) { FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); string check_result = CheckSummary(model); if (!string.IsNullOrEmpty(check_result)) { ViewBag.SubmitError = check_result; } InterfaceSummaryService summary_service = new SummaryService(); if (ModelState.IsValid && string.IsNullOrEmpty(check_result)) { t_summary add_summary = new t_summary(); add_summary.summ_desc = model.add_summary; add_summary.mana_id = mana_id; add_summary.sort_by = 10000; try { summary_service.Insert(add_summary); } catch { } } else { List <t_summary> summary_list = new List <t_summary>(); try { summary_list = summary_service.SearchByManagerID(mana_id).ToList(); } catch { } ViewBag.DATA = JsonConvert.SerializeObject(summary_list); return(View()); } return(RedirectToAction("SummaryType", "Financing")); }
private void PopulateList() { var history = HistoryService.GetHistory(); AppliedLeaveList = new ObservableCollection <AppliedLeave>(); AppliedLeaveList.Clear(); foreach (AppliedLeave leave in history) { AppliedLeaveList.Add(leave); } var summary = SummaryService.GetSummary(); LeaveList = new ObservableCollection <LeaveObject>(); LeaveList.Clear(); foreach (LeaveObject leave in summary) { LeaveList.Add(leave); } }
public ActionResult SavePercent(int budgetPlanCategoryId, string allocatedPercent) { BudgetPlanningService s = new BudgetPlanningService(); int budgetPlanId = s.GetSelectedBudgetPlan(); SummaryService ss = new SummaryService(); decimal temp = 0; allocatedPercent = allocatedPercent.Replace('%', (char)0); if (Decimal.TryParse(allocatedPercent, out temp)) { BudgetPlanCategoryDto b = new BudgetPlanCategoryDto(); b.BudgetPlanCategoryId = budgetPlanCategoryId; b.AllocatedPercentage = allocatedPercent; b.UsePercent = true; s.SaveBudgetPlanCategory(b); } else { ModelState.AddModelError(string.Empty, "Allocated percentage cannot be parsed as a decimal number. Please make sure Percent is a number."); } return(BudgetPlanCategoryListing(budgetPlanId)); }
private string CheckSearchRecord(string s_date, string e_date, int record_type, int summary) { string result = ""; DateTime start_date_datetime; DateTime end_date_datetime; bool try_start_date_result = DateTime.TryParse(s_date, out start_date_datetime); bool try_end_date_result = DateTime.TryParse(e_date, out end_date_datetime); if (try_start_date_result && try_end_date_result) { InterfaceRecordTypeService record_type_service = new RecordTypeService(); InterfaceSummaryService summary_service = new SummaryService(); t_record_type record_type_find = null; try { record_type_find = record_type_service.SearchByCode(record_type).FirstOrDefault(); } catch {} if (record_type_find == null && record_type != -1) { result = HtmlExtensions.Lang("_Error_Financing_RecordDetail_RecordType"); } else { t_summary summary_find = summary_service.GetByID(summary); if (summary_find == null && summary != -1) { result = HtmlExtensions.Lang("_Error_Financing_RecordDetail_Summary"); } } } else { result = HtmlExtensions.Lang("_Error_Financing_RecordDetail_Date"); } return(result); }
public void AddBusinessMessage(RmsReportMonitoringRaw rawMessage) { try { var ip = GetIP(); rawMessage.ClientIpAddress = ip; using (var db = new MyDbContext()) { db.Configuration.AutoDetectChangesEnabled = false; db.RmsReportMonitoringRaws.Add(rawMessage); db.SaveChanges(); } if (string.IsNullOrEmpty(rawMessage.ClientCode)) { return; } if (string.IsNullOrEmpty(rawMessage.MessageGroupCode)) { return; } if (string.IsNullOrEmpty(rawMessage.Message)) { return; } var sv = new SummaryService(); var caller = new SummaryService.DoSummaryMonitoringForBusinessAsync(sv.DoSummaryMonitoringForBusiness); caller.BeginInvoke(rawMessage, null, null); } catch (Exception ex) { new RMSWebException(this, "0500", "AddBusinessMessage failed. " + ex.Message, ex, true); } }
//private readonly MasterDataRepository masterDataRepository; //private readonly MasterDataService masterDataService; //private readonly AccountService accountService; //private readonly SecurityService securityService; //private readonly GlobalCacheRepository globalCache; //public const string GLOBAL = "Global"; //public const string LOCAL = "Local"; //public SystemController(MasterDataRepository masterDataRepository, // GlobalCacheRepository globalCache, // MasterDataService masterDataService, // AccountService accountService, // SecurityService securityService) { // this.masterDataRepository = masterDataRepository; // this.masterDataService = masterDataService; // this.accountService = accountService; // this.securityService = securityService; // this.globalCache = globalCache; //} public SystemController(SummaryService summaryService) { this.summaryService = summaryService; }