コード例 #1
0
        public ActionResult Create([Bind(Include = "AssetId,OwnerId,Address,City,State,ZipCode,Bedrooms,Bathrooms,HomeValue,FilePath")] Asset asset)
        {
            if (ModelState.IsValid)
            {
                db.Assets.Add(asset);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OwnerId = new SelectList(db.Owners, "UserId", "EthAdd", asset.OwnerUserId);
            return(View(asset));
        }
コード例 #2
0
        public ActionResult AddContract(AssetVM assetVM)
        {
            if (ModelState.IsValid)
            {
                var model  = assetVM.ConvertToAsset();
                var owners = db.Owners.Find(assetVM.OwnerUserId);


                db.Assets.Add(model);
                db.SaveChanges();

                CreateContract(assetVM.PrivateKey, owners.EthAdd);
                return(RedirectToAction("Index", "Asset"));
            }
            return(View(assetVM));
        }
コード例 #3
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    var owner = new Owner {
                        UserId = user.Id, EthAdd = model.EthAdd
                    };
                    using (var db = new HOMEEntities())
                    {
                        db.Owners.Add(owner);
                        db.SaveChanges();
                    }
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);


                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }