Exemplo n.º 1
0
        // Create Method
        public bool CreateEthicalOrganization(ECreate model)
        {
            var entity =
                new EthicalOrganization()
            {
                Id = _userId,
                EthicalOrganizationName = model.EthicalOrganizationName,
                CrueltyFree             = model.CrueltyFree,
                Sustainable             = model.Sustainable,
                Diverse  = model.Diverse,
                ECountry = model.ECountry,
                EImprove = model.EImprove
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.EthicalOrganizations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(ECreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateEthicalService();

            if (service.CreateEthicalOrganization(model))
            {
                TempData["SaveResult"] = "Your organization was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Organization could not be created.");

            return(View(model));
        }