Exemplo n.º 1
0
        public bool CreateExComponent(ExComponentCreate model)
        {
            var entity =
                new ExComponent()
            {
                Address                = (string)model.Address,
                Foundation             = model.Foundation,
                FoundationCondition    = model.FoundationCondition,
                FloorStructure         = model.FloorStructure,
                FloorCondition         = model.FloorCondition,
                ExteriorWalls          = model.ExteriorWalls,
                WallCondition          = model.WallCondition,
                RoofFraming            = model.RoofFraming,
                RoofFrame              = model.RoofFrame,
                RoofCover              = model.RoofCover,
                RoofCondition          = model.RoofCondition,
                ChimneyType            = model.ChimneyType,
                ChimneyCondition       = model.ChimneyCondition,
                RoofDrainage           = model.RoofDrainage,
                DrainageCondition      = model.DrainageCondition,
                WallCover              = model.WallCover,
                WallCovers             = model.WallCovers,
                EavesSoffitsFascia     = model.EavesSoffitsFascia,
                EavesSoffitsAndFascia  = model.EavesSoffitsAndFascia,
                ExteriorDoors          = model.ExteriorDoors,
                ExtDoorCondition       = model.ExtDoorCondition,
                Driveways              = model.Driveways,
                DriveCondition         = model.DriveCondition,
                Walkways               = model.Walkways,
                WalkCondition          = model.WalkCondition,
                GarageDoors            = model.GarageDoors,
                GarageDoorCond         = model.GarageDoorCond,
                PorchAndPatio          = model.PorchAndPatio,
                PorchCondition         = model.PorchCondition,
                SurfaceDrainage        = model.SurfaceDrainage,
                SurfaceDrainCondition  = model.SurfaceDrainCondition,
                RetainingWall          = model.RetainingWall,
                RetainingWallCondition = model.RetainingWallCondition,
                Fencing                = model.Fencing,
                FenceCondition         = model.FenceCondition
            };

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

            var service = CreateExComponentService();

            if (service.CreateExComponent(model))
            {
                TempData["SaveResult"] = "Our Property has been created.";
                return(RedirectToAction("Index"));
            }

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

            return(View(model));
        }