Esempio n. 1
0
        public IActionResult WeightMultiplier(UserTransactionViewModel vm)
        {
            var weightMultiplier = new WeightMultiplier();

            var id = User.Identity.GetUserId();

            var weightModel = _weightMultiplierBO.List().Result.Where(w => w.AspNetUserId == id).FirstOrDefault();

            if (weightModel == null)
            {
                weightMultiplier.WeightNumberAssetsToLiabilities = vm.WeightNumberAssetsToLiabilities;
                weightMultiplier.WeightNumberDebtToEquity        = vm.WeightNumberDebtToEquity;
                weightMultiplier.WeightNumberEPS     = vm.WeightNumberEPS;
                weightMultiplier.WeightNumberEquity  = vm.WeightNumberEquity;
                weightMultiplier.WeightNumberPERatio = vm.WeightNumberPERatio;
                weightMultiplier.WeightNumberRevenue = vm.WeightNumberRevenue;
                weightMultiplier.WeightNumberRoic    = vm.WeightNumberRoic;
                weightMultiplier.AspNetUserId        = User.Identity.GetUserId();
                _weightMultiplierBO.Create(weightMultiplier);
            }
            else
            {
                weightModel.WeightNumberAssetsToLiabilities = vm.WeightNumberAssetsToLiabilities;
                weightModel.WeightNumberDebtToEquity        = vm.WeightNumberDebtToEquity;
                weightModel.WeightNumberEPS     = vm.WeightNumberEPS;
                weightModel.WeightNumberEquity  = vm.WeightNumberEquity;
                weightModel.WeightNumberPERatio = vm.WeightNumberPERatio;
                weightModel.WeightNumberRevenue = vm.WeightNumberRevenue;
                weightModel.WeightNumberRoic    = vm.WeightNumberRoic;
                _weightMultiplierBO.Update(weightModel);
            }
            return(RedirectToAction("UserTransactions"));
        }
Esempio n. 2
0
 public UserRecordsController()
 {
     this.userTransaction     = new UserTransaction();
     this._noteBO             = new NoteBusinessObject();
     this._weightMultiplierBO = new WeightMultiplierBusinessObject();
     this.model    = new UserTransactionViewModel();
     this.analysis = new AnalysisBusinessObject();
 }
Esempio n. 3
0
        public IActionResult UserTransactions()
        {
            var model = new UserTransactionViewModel();

            model.AspNetUserId = User.Identity.GetUserId();

            var portfolioBusiness = new PortfolioBusinessObject();
            var result            = portfolioBusiness.GetUserPortfolio(User.Identity.GetUserId());

            model.CompaniesTransactions = result.CompaniesTransactions;
            model.TotalTransactions     = result.TotalTransactions;
            var weightModel = _weightMultiplierBO.List().Result.Where(w => w.AspNetUserId == model.AspNetUserId).FirstOrDefault();

            if (weightModel != null)
            {
                model.WeightNumberAssetsToLiabilities = weightModel.WeightNumberAssetsToLiabilities;
                model.WeightNumberDebtToEquity        = weightModel.WeightNumberDebtToEquity;
                model.WeightNumberEPS     = weightModel.WeightNumberEPS;
                model.WeightNumberEquity  = weightModel.WeightNumberEquity;
                model.WeightNumberPERatio = weightModel.WeightNumberPERatio;
                model.WeightNumberRevenue = weightModel.WeightNumberRevenue;
                model.WeightNumberRoic    = weightModel.WeightNumberRoic;
            }

            var analysis       = new AnalysisBusinessObject();
            var stockItemPocos = analysis.GetStockData();
            var companyList    = new List <Company>();

            foreach (var item in stockItemPocos)
            {
                var company = item.CompanyDataPoco.Company;
                companyList.Add(company);
            }
            model.Companies = companyList;

            ViewBag.CompanyNames = model.Companies.Select(company => new SelectListItem()
            {
                Text = company.Name, Value = company.Id.ToString()
            });

            return(View(model));
        }
        public IActionResult HomePage(int userid)
        {
            int?loggedUser = HttpContext.Session.GetInt32("userid");

            if (userid != loggedUser)
            {
                return(RedirectToAction("Index", "User"));
            }

            User returnedUser = _context.Users.Where(p => p.userid == userid).FirstOrDefault();

            List <Transaction> everyTrans = _context.Transactions.Where(p => p.userid == loggedUser).ToList();
            var ViewThing = new UserTransactionViewModel()
            {
                user = returnedUser, tranList = everyTrans
            };

            Console.WriteLine("GOT TRANSACTIONS");

            return(View(ViewThing));
        }
Esempio n. 5
0
        public ActionResult Index()
        {
            if (Session["UserInfo"] != null)
            {
                var user                 = Session["UserInfo"] as User;
                var transactionList      = new List <Transaction>();
                var transactionModelList = new List <UserTransactionViewModel>();
                var gameList             = new TransactionModel().GamesList;
                var partnerList          = new TransactionModel().PaymentPartners;

                using (var context = new GameNepalEntities())
                {
                    var userTransactions = (from trans in context.Transactions
                                            join usr in context.Users on trans.userid equals usr.id
                                            select new
                    {
                        usr.firstname,
                        usr.lastname,
                        usr.email,
                        usr.phone,
                        trans.id,
                        trans.updatedate,
                        trans.paypartnerid,
                        trans.paymentid,
                        trans.amount,
                        trans.status,
                        trans.username,
                        trans.gameid,
                        trans.remarks
                    }).OrderByDescending(x => x.updatedate)
                                           .ToList();

                    foreach (var transaction in userTransactions)
                    {
                        var transactionModel = new UserTransactionViewModel
                        {
                            TransactionId             = transaction.id,
                            LastTransactionUpdateDate = transaction.updatedate,
                            FirstName = transaction.firstname,
                            LastName  = transaction.lastname,
                            Email     = transaction.email,
                            Phone     = transaction.phone,
                            PaymentId = transaction.paymentid,
                            Amount    = transaction.amount,
                            Status    = transaction.status,
                            Username  = transaction.username,
                            Remarks   = transaction.remarks
                        };


                        transactionModel.CurrentStatus = Helper.GetCurrentTransactionStatus(transaction.status);
                        transactionModel.Game          = gameList
                                                         .Where(x => x.Value.Equals(transaction.gameid.ToString()))
                                                         .Select(x => x.Text).FirstOrDefault();

                        transactionModel.PaymentPartner = partnerList
                                                          .Where(x => x.Value.Equals(transaction.paypartnerid.ToString()))
                                                          .Select(x => x.Text).FirstOrDefault();

                        if (string.IsNullOrEmpty(transactionModel.PaymentPartner))
                        {
                            transactionModel.PaymentPartner = "N/A";
                        }

                        transactionModelList.Add(transactionModel);
                    }
                }

                ViewBag.UserName = user.firstname;
                return(View(transactionModelList));
            }
            return(RedirectToAction("Login", "Home"));
        }
Esempio n. 6
0
        public IActionResult UserTransactions(UserTransactionViewModel vm)
        {
            var model           = new UserTransactionViewModel();
            var userTransaction = new UserTransaction();

            userTransaction.AspNetUserId = User.Identity.GetUserId();
            model.AspNetUserId           = User.Identity.GetUserId();

            if (vm.ValueOfShares != null)
            {
                model.CompanyId      = vm.CompanyId;
                model.DateOfMovement = vm.DateOfMovement;

                userTransaction.CompanyId      = vm.CompanyId;
                userTransaction.DateOfMovement = vm.DateOfMovement;

                if (vm.IsAPurchaseOrSale == 0)
                {
                    model.NumberOfShares = vm.NumberOfShares;
                    model.ValueOfShares  = vm.ValueOfShares;

                    userTransaction.NumberOfShares          = vm.NumberOfShares;
                    userTransaction.ValueOfShares           = vm.ValueOfShares;
                    userTransaction.NumberOfSharesWithdrawn = 0;
                    userTransaction.ValueOfSharesWithdrawn  = 0;
                }
                else
                {
                    model.NumberOfSharesWithdrawn = vm.NumberOfShares;
                    model.ValueOfSharesWithdrawn  = vm.ValueOfShares;

                    userTransaction.NumberOfShares          = 0;
                    userTransaction.ValueOfShares           = 0;
                    userTransaction.NumberOfSharesWithdrawn = vm.NumberOfShares;
                    userTransaction.ValueOfSharesWithdrawn  = vm.ValueOfShares;
                }



                var portfolioBusiness = new PortfolioBusinessObject();
                var result            = portfolioBusiness.GetUserPortfolio(User.Identity.GetUserId());

                model.CompaniesTransactions = result.CompaniesTransactions;
                model.TotalTransactions     = result.TotalTransactions;

                var analysis       = new AnalysisBusinessObject();
                var stockItemPocos = analysis.GetStockData();
                var companyList    = new List <Company>();
                foreach (var item in stockItemPocos)
                {
                    var company = item.CompanyDataPoco.Company;
                    companyList.Add(company);
                }
                model.Companies = companyList;

                ViewBag.CompanyNames = model.Companies.Select(company => new SelectListItem()
                {
                    Text = company.Name, Value = company.Id.ToString()
                });


                var createOperation = _userTransactionBO.Create(userTransaction);

                Response.Redirect("UserTransactions");
            }

            //Caso seja introduzida uma transação e o utilizador não se lembrar do value da compra
            if (vm.ValueOfShares == null && vm.NumberOfShares != null)
            {
                var stockValues = _stockValuesBO.GetStockValuesPerYear(vm.CompanyId);
                var valueInYear = stockValues.Components.Where(x => x.Year == vm.DateOfMovement.Year);
                var marketCap   = valueInYear.Select(x => x.MarketCap).SingleOrDefault();
                var sharesBasic = valueInYear.Select(x => x.SharesBasic).SingleOrDefault();
                var stockValue  = marketCap / sharesBasic;


                model.CompanyId      = vm.CompanyId;
                model.DateOfMovement = vm.DateOfMovement;

                userTransaction.CompanyId      = vm.CompanyId;
                userTransaction.DateOfMovement = vm.DateOfMovement;

                if (vm.IsAPurchaseOrSale == 0)
                {
                    model.NumberOfShares = vm.NumberOfShares;
                    model.ValueOfShares  = stockValue;

                    userTransaction.NumberOfShares          = vm.NumberOfShares;
                    userTransaction.ValueOfShares           = stockValue;
                    userTransaction.NumberOfSharesWithdrawn = 0;
                    userTransaction.ValueOfSharesWithdrawn  = 0;
                }
                else
                {
                    model.NumberOfSharesWithdrawn = vm.NumberOfShares;
                    model.ValueOfSharesWithdrawn  = stockValue;

                    userTransaction.NumberOfShares          = 0;
                    userTransaction.ValueOfShares           = 0;
                    userTransaction.NumberOfSharesWithdrawn = vm.NumberOfShares;
                    userTransaction.ValueOfSharesWithdrawn  = stockValue;
                }

                var portfolioBusiness = new PortfolioBusinessObject();
                var result            = portfolioBusiness.GetUserPortfolio(User.Identity.GetUserId());

                model.CompaniesTransactions = result.CompaniesTransactions;
                model.TotalTransactions     = result.TotalTransactions;

                var analysis       = new AnalysisBusinessObject();
                var stockItemPocos = analysis.GetStockData();
                var companyList    = new List <Company>();
                foreach (var item in stockItemPocos)
                {
                    var company = item.CompanyDataPoco.Company;
                    companyList.Add(company);
                }
                model.Companies = companyList;

                ViewBag.CompanyNames = model.Companies.Select(company => new SelectListItem()
                {
                    Text = company.Name, Value = company.Id.ToString()
                });

                var createOperation = _userTransactionBO.Create(userTransaction);

                Response.Redirect("UserTransactions");
            }

            return(View(model));
        }