Exemple #1
0
        public ActionResult Sell([Bind(Include = "AskId,AskPrice,TimeStamp,Quantity,StockName,UserId")] SellingTable sellingTable)
        {
            string user    = User.Identity.Name;
            var    context = new IdentityDbContext();
            var    uid     = context.Users.FirstOrDefault(x => x.UserName == user);

            sellingTable.UserId = uid.Id;
            int intValue = 1287926608;

            sellingTable.TimeStamp = BitConverter.GetBytes(intValue);
            if (ModelState.IsValid)
            {
                int       a         = (int)TempData["data"];
                Portfolio portfolio = db.Portfolios.Find(a);
                int       c         = portfolio.ShareQuantity;
                if (sellingTable.Quantity > portfolio.ShareQuantity)
                {
                    ViewBag.Message = "You donot have the required Quantity" + "  Available Shares =" + portfolio.ShareQuantity;
                    return(View());
                }

                db.SellingTables.Add(sellingTable);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sellingTable));
        }
Exemple #2
0
        // GET: SellingTables/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SellingTable sellingTable = db.SellingTables.Find(id);

            if (sellingTable == null)
            {
                return(HttpNotFound());
            }
            return(View(sellingTable));
        }
Exemple #3
0
        // GET: SellingTables/Create
        public ActionResult Sell(int?id)
        {
            Portfolio portfolio = db.Portfolios.Find(id);

            TempData["data"] = id;
            SellingTable sellingTable = new SellingTable();

            sellingTable.StockName = portfolio.StockName;
            string user    = User.Identity.Name;
            var    context = new IdentityDbContext();
            var    uid     = context.Users.FirstOrDefault(x => x.UserName == user);

            sellingTable.UserId = uid.Id;
            return(View(sellingTable));
        }