Пример #1
0
        public ActionResult Create(string OwnerID)
        {
            if (OwnerID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var owner = DefaultConnection.Owners.Find(OwnerID);

            if (!owner.UserID.Equals(User.Identity.GetUserId()))
            {
                DataSerializer <string> .SecurityPriorityNumberOne(User.Identity.GetUserId());

                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }
            encryptionServices = new EncryptionServices();
            TraderAccount model = new TraderAccount();

            model.OwnerID = OwnerID;
            model         = encryptionServices.EncryptTraderAccount(model);
            DefaultConnection.TraderAccounts.Add(new TraderAccount()
            {
                TradingAccountID = model.TradingAccountID,
                OwnerID          = model.OwnerID,
                CreationDate     = DateTime.Now,
                Balance          = 1000000
            });
            DefaultConnection.SaveChanges();

            return(RedirectToAction("Details", new
            {
                TradingAccountID = model.TradingAccountID.ToString()
            }));
        }