Ejemplo n.º 1
0
        public bool CreateFosterHome(FosterHomeCreate model)
        {
            var entity = new FosterHome()
            {
                HomeId            = model.HomeId,
                FamilyName        = model.FamilyName,
                OpenBeds          = model.OpenBeds,
                GenderPref        = model.GenderPref,
                AgePrefMin        = model.AgePrefMin,
                AgePrefMax        = model.AgePrefMax,
                SchoolDistrict    = model.SchoolDistrict,
                Agency            = model.Agency,
                CaseworkerName    = model.CaseworkerName,
                CaseworkerContact = model.CaseworkerContact,
                PhotoUrl          = model.PhotoUrl,
                ModifiedUtc       = model.ModifiedUtc,
                Comments          = model.Comments,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Homes.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(FosterHomeCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateFosterHomeService();

            if (service.CreateFosterHome(model))
            {
                TempData["SaveResult"] = "The Foster Home was created.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Foster Home could not be created.");

            return(View(model));
        }