Exemplo n.º 1
0
        //[Authorize(Roles = "Administrator")]
        public ActionResult EditPrice(int Id)
        {
            if (Session["userId"] != null && Session["userId"].Equals(_username))
            {
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }

            ActualTransactions theTransaction = dbcontext.ActualTransactions.Find(Id);

            ViewBag.TheStrategy = theTransaction.Strategy;

            return(View(theTransaction));
        }
Exemplo n.º 2
0
        //[Authorize(Roles = "Administrator")]
        public ActionResult EditPrice(ActualTransactions actualTransaction)
        {
            if (Session["userId"] != null && Session["userId"].Equals(_username))
            {
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }

            ActualTransactions transactionToSave = dbcontext.ActualTransactions.Find(actualTransaction.ID);

            transactionToSave.ActualLABUStartingPrice = actualTransaction.ActualLABUStartingPrice;
            transactionToSave.ActualLABUEndingPrice   = actualTransaction.ActualLABUEndingPrice;
            transactionToSave.ActualLABDStartingPrice = actualTransaction.ActualLABDStartingPrice;
            transactionToSave.ActualLABDEndingPrice   = actualTransaction.ActualLABDEndingPrice;

            dbcontext.SaveChanges();
            return(RedirectToAction("EditTransactionsPage"));;
        }
Exemplo n.º 3
0
        public ActionResult InsertNewTrades()
        {
            List <ActualTransactions> transactionsDetails = new List <ActualTransactions>();

            var transactions = dbcontext.GetTrades();

            foreach (var item in transactions)
            {
                ActualTransactions details = new ActualTransactions();
                details.ID   = item.ID;
                details.Date = item.Date;
                details.StartingLABUPrice = item.StartingLABUPrice;
                details.StartingLABDPrice = item.StartingLABDPrice;
                details.Strategy          = item.Strategy;
                details.StartingType      = item.StartingType;
                details.Shares            = item.Shares;
                details.EndingLABUPrice   = item.EndingLABUPrice;
                details.EndingLABDPrice   = item.EndingLABDPrice;
                details.Type   = item.Type;
                details.Reason = item.Reason;
                details.ActualLABUStartingPrice = "";
                details.ActualLABDStartingPrice = "";
                details.ActualLABUEndingPrice   = "";
                details.ActualLABDEndingPrice   = "";
                details.EndDate = item.EndDate;

                transactionsDetails.Add(details);
            }

            transactionsDetails.OrderBy(t => t.ID);
            ActualTransactions lastRecord = dbcontext.ActualTransactions.OrderByDescending(x => x.ID).FirstOrDefault();
            int    lastRecordID           = lastRecord.ID;
            string lastRecordTimestamp    = lastRecord.Date;

            bool DateMatch = false;
            int  counter   = 0;
            int  lastIDinActualTransactionTable = 0;
            int  numbOfNewTrades = 0;

            foreach (var item in transactionsDetails)
            {
                //if(item.ID > lastRecordID)
                //{
                //    dbcontext.ActualTransactions.Add(item);
                //    dbcontext.SaveChanges();
                //}

                if (item.Date.Equals(lastRecordTimestamp))
                {
                    DateMatch = true;
                    lastIDinActualTransactionTable = lastRecordID;
                }

                if (DateMatch)
                {
                    counter++;
                }

                if (counter > 1)
                {
                    lastIDinActualTransactionTable++;
                    item.ID = lastIDinActualTransactionTable;
                    dbcontext.ActualTransactions.Add(item);
                    dbcontext.SaveChanges();
                    numbOfNewTrades++;
                }
            }

            string jsonMessage = "";

            if (numbOfNewTrades == 1)
            {
                jsonMessage = "Inserted " + numbOfNewTrades + " new trade. ";
            }
            else
            {
                jsonMessage = "Inserted " + numbOfNewTrades + " new trades. ";
            }

            return(Json(new { success = jsonMessage }, JsonRequestBehavior.AllowGet));
        }