コード例 #1
0
        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            OwnerModel owner = (OwnerModel)OwnerList.SelectedItem;

            if (owner != null)
            {
                Investment            = new InvestmentModel();
                Investment.Staff      = PublicVariables.Staff;
                Investment.Store      = PublicVariables.Store;
                Investment.Date       = DateTime.Now;
                Investment.TotalMoney = (decimal)InvestmentValue.Value;

                GlobalConfig.InvestmentValidator = new InvestmentValidator();
                ValidationResult result = GlobalConfig.InvestmentValidator.Validate(Investment);

                if (result.IsValid == false)
                {
                    MessageBox.Show(result.Errors[0].ErrorMessage);
                }
                else
                {
                    GlobalConfig.Connection.AddInvestmentToTheDatabase(Investment, owner);
                    SetInitialValues();
                }
            }
            else
            {
                MessageBox.Show("Select Owner Please");
            }
        }
コード例 #2
0
        public void Setup()
        {
            investmentModelWithGains = new InvestmentModel
            {
                InvestmentId         = 1,
                InvestmentName       = "Test",
                SharesOwned          = 10,
                CurrentPricePerShare = 3,
                CostBasisPerShare    = 2,
                Term = ShareTerm.LongTerm.ToString()
                       //expected CurrentValue = 30
                       //expected TotalGainLoss = +10
            };

            investmentModelWithLosses = new InvestmentModel
            {
                InvestmentId         = 1,
                InvestmentName       = "Test",
                SharesOwned          = 10,
                CurrentPricePerShare = 2,
                CostBasisPerShare    = 3,
                Term = ShareTerm.LongTerm.ToString()
                       //expected CurrentValue = 20
                       //expected TotalGainLoss = -10
            };
        }
コード例 #3
0
        public static Investment ToModelToEntity(this InvestmentModel model)
        {
            var investment = new Investment {
                ListItemsInvestment = model.ListItemsInvestmentModel.Select(x => x.ModelToEntity()).ToList()
            };

            return(investment);
        }
コード例 #4
0
        public async Task QuandoRealizoUmaOeracaoFinanceiraDeReais(string value)
        {
            Investment investment = new Investment()
            {
                User             = "******",
                InvestimentValue = value
            };

            this.investmentModel = await InvestmentRepository.MakeInvestment(investment);
        }
コード例 #5
0
        public static double SumInvestment(this InvestmentModel model)
        {
            double sumInvestment = 0;

            foreach (ItemModel item in model.ListItemsInvestmentModel)
            {
                sumInvestment += item.HowMuch;
            }

            return(sumInvestment);
        }
コード例 #6
0
 public ActionResult AuditInvestment(InvestmentModel model)
 {
     try
     {
         model.AuditUser = CurrentUser.Id;
         return(Json(new JsonMessage(service.AuditInvestment(model))));
     }
     catch (Exception e)
     {
         return(Json(new JsonMessage(false, e.Message)));
     }
 }
コード例 #7
0
        public static async Task <InvestmentModel> MakeInvestment(Investment investment)
        {
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var url = $"{Constants.URL}{Constants.ENDPOINT_INVESTMENT}";

            var requestBody = new StringContent(JsonConvert.SerializeObject(investment));

            HttpResponseMessage response = await client.PostAsync(url, requestBody);

            InvestmentModel investmentModel = null;

            if (response.IsSuccessStatusCode)
            {
                string responseBody = await response.Content.ReadAsStringAsync();

                investmentModel = JsonConvert.DeserializeObject <InvestmentModel>(responseBody);
            }

            return(investmentModel);
        }
コード例 #8
0
        /// <summary>
        /// 获取图表现金流量
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, List <decimal> > getFlowService(string start_date, string stop_date)
        {
            //获取token
            string token = FinanceToken.getFinanceCheckToken().getToken();
            //返回的map
            Dictionary <string, List <decimal> > result = null;

            if (account != null)
            {
                //创建实例
                result = new Dictionary <string, List <decimal> >();
                //年初借金数组
                List <decimal> sumYear = new List <decimal>();
                //年初贷金数组
                List <decimal> sumMonth = new List <decimal>();
                //投资结余
                ManagementModel management = new ManagementModel();
                //筹资结余
                InvestmentModel investment = new InvestmentModel();
                //经营结余
                FinancingModel financing = new FinancingModel();

                //今年结余
                sumYear.Add(management.getManagementYear(account.company, start_date, stop_date));
                sumYear.Add(investment.getInvestmentYear(account.company, start_date, stop_date));
                sumYear.Add(financing.getFinancingYear(account.company, start_date, stop_date));
                //当月结余
                sumMonth.Add(management.getManagementMonth(account.company, start_date, stop_date));
                sumMonth.Add(investment.getInvestmentMonth(account.company, start_date, stop_date));
                sumMonth.Add(financing.getFinancingMonth(account.company, start_date, stop_date));
                //return
                result.Add("sumYear", sumYear);
                result.Add("sumMonth", sumMonth);
            }
            return(result);
        }
コード例 #9
0
 public ActionResult SubmitInvestment(InvestmentModel model)
 {
     model.UpdateUser = CurrentUser.Id;
     return(Json(new JsonMessage(service.SaveInvestment(model, true))));
 }