예제 #1
0
        public ActionResult Create(CustomerBank customerbank)
        {
            if (ModelState.IsValid)
            {
                customerbank.CustomerId = db.Customers.Where(s => s.UserId == UserID).First().CustomerId;
                db.CustomerBanks.Add(customerbank);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customerbank));
        }
예제 #2
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password, null, true);

                    DbContext db = new DbContext("DefaultConnection");

                    //Add User Email Address
                    using (DiamondCircle_dbEntities dbs = new DiamondCircle_dbEntities())
                    {
                        UserDetail newuser = new UserDetail();
                        newuser.UserId = WebSecurity.GetUserId(model.UserName);
                        newuser.Email  = model.Email;
                        dbs.UserDetails.Add(newuser);
                        dbs.SaveChanges();

                        //Make sure they have a customer record created at the same time
                        Customer customer = new Customer();
                        //TODO: Converting and Int Id to a string is really messy
                        customer.UserId     = newuser.UserId.ToString();
                        customer.CreateDate = DateTime.Now;
                        dbs.Customers.Add(customer);
                        dbs.SaveChanges();
                    }


                    WebSecurity.ConfirmAccount(model.UserName);

                    //NO!  TODO:
                    //Send cofirmation email
                    string query = "select ConfirmationToken from webpages_Membership where UserId = (select UserId from UserProfile where UserName ='******')";
                    string body  = "Dear " + model.UserName + ",\n\r To activate  your username click link below: \n\r  "
                                   + string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~")) + "Account/Confirm/?str=" + db.Database.SqlQuery <string>(query, model.UserName).FirstOrDefault() + " \n\r \n\r  Regards,";;

                    SendEmail.Send("Diamond Circle", model.Email, "Activation link", body);

                    TempData["Msg"] = "An activation link has been sent to your email address.";

                    return(RedirectToAction("Message", "Home"));
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
예제 #3
0
        public ActionResult Create(CreditCard model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                using (var atmClient = new DC.CardService.CardClient())
                {
                    try
                    {
                        string cardId;

                        using (var db = new DiamondCircle_dbEntities())
                        {
                            var savedCard = db.CreditCards.Add(model);
                            db.SaveChanges();

                            //Get the DC card for this user
                            cardId = model.Cards.First().CardId;
                            var card = db.Cards.Where(c => c.CardId == cardId).First();
                            card.CreditCardId = savedCard.CreditCardId;
                            db.SaveChanges();
                        }

                        if (string.IsNullOrEmpty(returnUrl))
                        {
                            return(RedirectToAction("AddCardSuccessful", new { abbrevCardNum = MaskCardNumber(model.CardNumber) }));
                        }
                        else
                        {
                            var urlVals = returnUrl.Split(',');
                            if (urlVals.Length == 1)
                            {
                                return(RedirectToAction(urlVals[0], urlVals[1]));
                            }
                            else
                            {
                                return(RedirectToAction(returnUrl));
                            }
                        }
                    }
                    catch (ArgumentException argEx)
                    {
                        ModelState.AddModelError(string.Empty, argEx.Message);
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }
                }
            }

            return(View(model));
        }
예제 #4
0
        public ActionResult Create(Address address)
        {
            if (ModelState.IsValid)
            {
                address.CustomerId = db.Customers.Where(s => s.UserId == UserID).First().CustomerId;
                db.Addresses.Add(address);

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryId = new SelectList(db.countries, "Id", "name", address.CountryId);
            return(View(address));
        }
예제 #5
0
        public void CreateCard()
        {
            using (var atmClient = new DC.AtmService.AtmClient())
            {
                using (var cardClient = new DC.CardService.CardClient())
                {
                    var keys = atmClient.CreatePublicEncryptedPrivateKey();

                    var card = new Card();
                    card.CardId = "eeeee111";
                    var privateKey = Convert.ToBase64String(keys.EncryptedWIFPrivateKey);
                    //card.Password = Convert.ToBase64String(keys.Password);
                    card.TempPublicKey = keys.PublicKey;
                    card.DateIssued    = DateTime.Now;

                    using (var db = new DiamondCircle_dbEntities())
                    {
                        var userId = WebSecurity.CurrentUserId.ToString();
                        //card.CustomerID = db.Customers.Where(s => s.UserId == userId).SingleOrDefault().CustomerId;

                        db.Cards.Add(card);
                        db.SaveChanges();
                    }
                }
            }
        }
예제 #6
0
        public ActionResult Tag(TagModel tag)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //Check Portal User has CustomerID
                    Customer customer = new Customer();
                    customer.UserId = WebSecurity.CurrentUserId.ToString();
                    string UserID = WebSecurity.CurrentUserId.ToString();
                    if (db.Customers.Where(s => s.UserId == UserID).Count() == 0)
                    {
                        //Add new Record to Customer Table


                        customer.CreateDate = DateTime.Now;
                        db.Customers.Add(customer);
                        db.SaveChanges();

                        //Update customerID for card table

                        Card card = db.Cards.Where(s => s.CardId == tag.CardId).First();
                        card.CustomerID = customer.CustomerId;
                        db.SaveChanges();
                    }
                    else
                    {
                        //Update customerID for card table
                        Card card = (from s in db.Cards
                                     where s.CardId == tag.CardId
                                     select s).First();
                        card.CustomerID = db.Customers.Where(s => s.UserId == UserID).First().CustomerId;
                        db.SaveChanges();
                    }
                    TempData["Msg"] = "Tag Added.";


                    return(RedirectToAction("Message", "Home"));
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(View(tag));
        }
예제 #7
0
 public void DeleteCard(Card card)
 {
     using (var db = new DiamondCircle_dbEntities())
     {
         db.Cards.Remove(card);
         db.SaveChanges();
     }
 }
예제 #8
0
        public ActionResult Create(CreditCard model, bool buy)
        {
            if (ModelState.IsValid)
            {
                using (var atmClient = new DC.CardService.CardClient())
                {
                    try
                    {
                        string cardId;

                        using (var db = new DiamondCircle_dbEntities())
                        {
                            var savedCard = db.CreditCards.Add(model);
                            db.SaveChanges();

                            //Get the DC card for this user
                            cardId = model.Cards.First().CardId;
                            var card = db.Cards.Where(c => c.CardId == cardId).First();
                            card.CreditCardId = savedCard.CreditCardId;
                            db.SaveChanges();
                        }

                        if (buy)
                        {
                            return(RedirectToAction("BuyBitcoin", "BuyBitcoin", new { CardId = cardId }));
                        }
                        else
                        {
                            return(RedirectToAction("AddCardSuccessful", new { abbrevCardNum = MaskCardNumber(model.CardNumber) }));
                        }
                    }
                    catch (ArgumentException argEx)
                    {
                        ModelState.AddModelError(string.Empty, argEx.Message);
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }
                }
            }

            return(View(model));
        }
예제 #9
0
        public void Commit()
        {
            var newBalance = GetBalance() - Amount;

            using (var db = new DiamondCircle_dbEntities())
            {
                var card = db.Cards.Where(c => c.CardId == _cardId).First();
                card.CardCurrencies.Where(b => b.FiatCurrencyId == CurrencyId).First().Balance = (decimal)newBalance;
                db.SaveChanges();
            }
        }
예제 #10
0
 public ActionResult Edit(Card card)
 {
     if (ModelState.IsValid)
     {
         db.Entry(card).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "CustomerId", "UserId", card.CustomerID);
     return(View(card));
 }
예제 #11
0
        public ActionResult Create(HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file.ContentLength > 0)
                {
                    string RealfileName = UserID.ToString() + "_" + Seq(UserID) + Path.GetFileName(file.FileName);
                    //  var path = Path.Combine(Server.MapPath( + "\\Files", fileName);
                    // Retrieve storage account from connection string.
                    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                        ConfigurationManager.ConnectionStrings["StorageConnection"].ConnectionString);


                    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();


                    CloudBlobContainer container = blobClient.GetContainerReference("files");

                    CloudBlockBlob blockBlob = container.GetBlockBlobReference(RealfileName);



                    blockBlob.UploadFromStream(file.InputStream);


                    UploadFile newFile = new UploadFile();
                    newFile.UserId       = WebSecurity.CurrentUserId;
                    newFile.FileRealName = RealfileName;
                    newFile.FileName     = Path.GetFileName(file.FileName);
                    newFile.Createdate   = DateTime.Now;
                    db.UploadFiles.Add(newFile);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View());
        }
예제 #12
0
        static void Main(string[] args)
        {
            DiamondCircle_dbEntities db = new DiamondCircle_dbEntities();

            Console.Write("Enter email or enter to skip: ");
            String email = Console.ReadLine();

            Decimal?CustomerId = null;

            if (!String.IsNullOrEmpty(email))
            {
                UserDetail profile = db.UserDetails.First(p => p.Email == email);

                String   userId   = profile.UserId.ToString();
                Customer customer = db.Customers.First(c => c.UserId == userId);
                CustomerId = customer.CustomerId;
            }

            Console.Write("Enter card id to add to database: ");
            String cardId = Console.ReadLine();

            DC.AtmService.AtmClient client = new DC.AtmService.AtmClient();
            DC.AtmService.Keys      newKey = client.CreatePublicEncryptedPrivateKey();

            Card card = new Card()
            {
                CardId     = cardId,
                PublicKey  = newKey.PublicKey,
                Password   = Convert.ToBase64String(newKey.Password),
                CustomerID = CustomerId,
                DateIssued = DateTime.UtcNow
                             //Password =  newKey.Password
            };



            db.Cards.Add(card);
            db.SaveChanges();

            Console.Write("All done.  The bitcoin address is {0}", card.PublicKey);
            Console.ReadKey();
        }
예제 #13
0
        private decimal CreateCustomer(string firstName, string lastName, string address, string city, string zip, string state, int countryId, string telephone, DateTime dob, string emailAddress)
        {
            using (DiamondCircle_dbEntities db = new DiamondCircle_dbEntities())
            {
                var newAddress = new DC.Data.Address()
                {
                    AddressLine1 = address, Suburb = city, Postcode = zip, CountryId = countryId, State = state, Mobile = telephone, AddressTypeId = 2
                };
                var customer = new Customer()
                {
                    CreateDate = DateTime.Today, FirstName = firstName, DOB = dob, EmailAddress = emailAddress
                };
                customer.Addresses.Add(newAddress);
                db.Customers.Add(customer);

                db.SaveChanges();
                //Check if the customerId is returned on save
                var customerId = customer.CustomerId;
                return(customerId);
            }
        }