Esempio n. 1
0
        //[ValidateAntiForgeryToken]
        //public ActionResult PreCreate(ApplicationUser user)
        //{
        //    var organization = new NonprofitOrganization()
        //    {
        //        OrganizationName = user.OrganizationName,
        //        UserId = user.Id,
        //        User = user,
        //        Active = false,
        //        RegistrationCompleted = false,
        //        ShipAddress = null,
        //        DropAddress = null
        //    };

        //    if (ModelState.IsValid)
        //    {
        //        db.NonprofitOrganizations.Add(organization);
        //        db.SaveChanges(); //THROWING EXCEPTION HERE
        //        return View("RegistrationLanding");
        //    }

        //    return View("RegisterOrganization", "Account", organization);
        //}

        // GET: NonprofitOrganizations/Create
        public ActionResult Create()
        {
            //ViewBag.DropOffAddress = new SelectList(db.Addresses, "AddressId", "ContactPerson");
            //ViewBag.ShippingAddress = new SelectList(db.Addresses, "AddressId", "ContactPerson");

            BeginRegistrationViewModel viewModel = new BeginRegistrationViewModel()
            {
                Categories = db.OrganizationCategories.Distinct().ToList()
            };

            return(View(viewModel));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "OrganizationName,OrganizationWebsite,OrganizationPhone,CategoryId")] BeginRegistrationViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();
                NonprofitOrganization nonprofitOrganization = new NonprofitOrganization()
                {
                    Active = false,
                    RegistrationCompleted = false,
                    UserId              = userId,
                    User                = db.Users.Where(c => c.Id == userId).First(),
                    CategoryId          = viewModel.CategoryId,
                    Category            = db.OrganizationCategories.Where(c => c.CategoryId == viewModel.CategoryId).First(),
                    OrganizationName    = viewModel.OrganizationName,
                    OrganizationPhone   = viewModel.OrganizationPhone,
                    OrganizationWebsite = viewModel.OrganizationWebsite,
                };
                db.NonprofitOrganizations.Add(nonprofitOrganization);
                db.SaveChanges();
                return(View("RegistrationLanding"));
            }

            return(View(viewModel));
        }