示例#1
0
        public ActionResult Create(Community community)
        {
            if (ModelState.IsValid)
            {
                community.Id = Guid.NewGuid();
                db.Communities.AddObject(community);
                db.SaveChanges();

                var templateSceneIdString = this.Request.Form["templateSceneId"];
                if (!string.IsNullOrEmpty(templateSceneIdString))
                {
                    // NOTE: make sure community ID is already created when move to "code first"
                    using (var cms = new CmsEntities())
                    {
                        var scene = cms.Scenes.Attach(community.GetScene());
                        var templateSceneId = long.Parse(templateSceneIdString);
                        var templateScene = cms.Scenes.First(s => s.Id == templateSceneId);
                        scene.ApplyTemplate(cms, templateScene);
                        cms.SaveChanges();
                    }
                }
                return RedirectToAction("Index");
            }

            ViewBag.ZoneId = new SelectList(db.Zones, "Id", "Name", community.ZoneId);
            return View(community);
        }
示例#2
0
 /// <summary>
 /// Create a new Community object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="zoneId">Initial value of the ZoneId property.</param>
 /// <param name="urlId">Initial value of the UrlId property.</param>
 /// <param name="established">Initial value of the Established property.</param>
 /// <param name="remoteness">Initial value of the Remoteness property.</param>
 /// <param name="hasLake">Initial value of the HasLake property.</param>
 /// <param name="hasWaterFeature">Initial value of the HasWaterFeature property.</param>
 /// <param name="hasClubOrFacility">Initial value of the HasClubOrFacility property.</param>
 /// <param name="hasMountainView">Initial value of the HasMountainView property.</param>
 /// <param name="hasParksAndPathways">Initial value of the HasParksAndPathways property.</param>
 /// <param name="hasShoppingPlaza">Initial value of the HasShoppingPlaza property.</param>
 /// <param name="numberOfPlaygrounds">Initial value of the NumberOfPlaygrounds property.</param>
 /// <param name="numberOfDwellings">Initial value of the NumberOfDwellings property.</param>
 /// <param name="population">Initial value of the Population property.</param>
 public static Community CreateCommunity(global::System.Guid id, global::System.String name, global::System.Guid zoneId, global::System.String urlId, global::System.Int32 established, global::System.Int32 remoteness, global::System.Boolean hasLake, global::System.Boolean hasWaterFeature, global::System.Boolean hasClubOrFacility, global::System.Boolean hasMountainView, global::System.Boolean hasParksAndPathways, global::System.Boolean hasShoppingPlaza, global::System.Int32 numberOfPlaygrounds, global::System.Int32 numberOfDwellings, global::System.Int32 population)
 {
     Community community = new Community();
     community.Id = id;
     community.Name = name;
     community.ZoneId = zoneId;
     community.UrlId = urlId;
     community.Established = established;
     community.Remoteness = remoteness;
     community.HasLake = hasLake;
     community.HasWaterFeature = hasWaterFeature;
     community.HasClubOrFacility = hasClubOrFacility;
     community.HasMountainView = hasMountainView;
     community.HasParksAndPathways = hasParksAndPathways;
     community.HasShoppingPlaza = hasShoppingPlaza;
     community.NumberOfPlaygrounds = numberOfPlaygrounds;
     community.NumberOfDwellings = numberOfDwellings;
     community.Population = population;
     return community;
 }
示例#3
0
 public ActionResult Edit(Community community)
 {
     if (ModelState.IsValid)
     {
         db.Communities.Attach(community);
         db.ObjectStateManager.ChangeObjectState(community, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Details", new { id = community.UrlId });
     }
     ViewBag.ZoneId = new SelectList(db.Zones, "Id", "Name", community.ZoneId);
     return View(community);
 }
示例#4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Communities EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCommunities(Community community)
 {
     base.AddObject("Communities", community);
 }