private void CreateStoreDDitems(Sublocation sublocation) { ViewBag.StoreID = new SelectList(rb.AllV <Store>(), "Id", "Name", sublocation.StoreID); //ViewBag.StoreID = new SelectList(rb.GetStores(), "Id", "Name", sublocation.StoreID); //ViewBag.StoreID = new SelectList(db.Stores, "Id", "Name", sublocation.StoreID); //this.ViewData["StoreID"] = new SelectList(db.Stores, "Id", "Name", sublocation.StoreID); }
public async Task <IActionResult> Edit(int id, [Bind("Id,SublocationName,Active,Location,Property")] Sublocation sublocation) { if (id != sublocation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sublocation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SublocationExists(sublocation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sublocation)); }
public ActionResult Create() { Sublocation newSloc = new Sublocation(); CreateStoreDDitems(newSloc); return(View(newSloc)); }
public ActionResult CreateSublocation(Sublocation model) { if (ModelState.IsValid) { try { db.Sublocations.Add(model); db.SaveChanges(); return(RedirectToAction("SublocationList")); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage); var errors = new List <string>(); foreach (var error in errorMessages) { errors.Add(error); } ViewBag.Errors = errors; } catch (Exception ex) { ViewBag.Errors = new List <string> { ex.Message }; } } return(View(model)); }
public async Task <IActionResult> Create([Bind("Id,SublocationName,Active,Location,Property")] Sublocation sublocation) { if (ModelState.IsValid) { _context.Add(sublocation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sublocation)); }
public ActionResult Details(int id = 0, int version = 0) { //Sublocation sublocation = db.Sublocations.Find(id, version); Sublocation sublocation = rb.Find <Sublocation>(id, version); if (sublocation == null) { return(HttpNotFound()); } return(View(sublocation)); }
public ActionResult Edit(int id = 0, int version = 0) { //Sublocation sublocation = db.Sublocations.Find(id, version); Sublocation sublocation = rb.Find <Sublocation>(id, version); if (sublocation == null) { return(HttpNotFound()); } CreateStoreDDitems(sublocation); return(View(sublocation)); }
public int GetCurrentSublocation(GameState gs) { LocationModel lm = gs.GetLM(); Sublocation sub = lm.GetSubLocation(); if (sub != null) { return(sub.GetSublocationID()); } else { return(0); } }
public ActionResult Edit(Sublocation sublocation) { if (ModelState.IsValid) { //Sublocation newItem = sublocation; //newItem.Version = sublocation.Version + 1; //newItem.EntryDate = DateTime.Now; //db.Sublocations.Add(newItem); //db.SaveChanges(); rb.Edit <Sublocation>(sublocation); return(RedirectToAction("Index")); } CreateStoreDDitems(sublocation); //this.ViewData["StoreID"] = new SelectList(db.Stores, "Id", "Name"); return(View(sublocation)); }
public ActionResult Create(Sublocation sublocation) { if (ModelState.IsValid) { //int iId = 1; //try //{ // iId = db.Sublocations.Max(t => t.ID) + 1; //} //catch { } //sublocation.ID = iId; //sublocation.Version = 1; //sublocation.EntryDate = DateTime.Now; //db.Sublocations.Add(sublocation); //db.SaveChanges(); rb.Create <Sublocation>(sublocation); return(RedirectToAction("Index")); } CreateStoreDDitems(sublocation); return(View(sublocation)); }
IEnumerator parseMapData() { yield return(new WaitUntil(() => csvLoadDone[0])); //this would mean that data is ready to be parsed int numSites = -1; int.TryParse(data[0, data.GetLength(1) - 1], out numSites); //get last site's index (=total num of sites) sites = new List <Site>(); int currSiteIdx = -1; //skip row 0 because those are all descriptors for (int r = 1; r < data.GetLength(1); r++) { int sidx = -1; int.TryParse(data[0, r], out sidx); if (sidx != currSiteIdx) //arrived at a new site row (if same, means this is a sublocation) { Dictionary <int, Sublocation> currSiteSublocations = new Dictionary <int, Sublocation>(); Site site = new Site(); sites.Add(site); site.sublocations = currSiteSublocations; site.siteName = data[2, r]; site.prefabName = data[5, r]; Vector2 siteLocation = new Vector2(); Global.parseVector2Parameter(data[4, r], ref siteLocation); site.coordinateOnMap = siteLocation; currSiteIdx = sidx; } else //is a sublocation row, needs to load in sublocation name and image { Sublocation sub = new Sublocation(); int subIndex = int.Parse(data[1, r]); sites[sites.Count - 1].sublocations.Add(subIndex, sub); sub.sublocationName = data[2, r]; sub.sublocationIndex = subIndex; bool showOnMap = bool.Parse(data[6, r]); sub.showOnMap = showOnMap; if (data[3, r] != "" && showOnMap) { var spr = Resources.Load <Sprite>("Images/Sites/" + data[3, r]); if (spr != null) { sub.displayImage = spr; //add sublocation image to "this site"'s group } else { Debug.LogError("load sublocation image failed: at " + "Images/Sites/" + data[3, r]); sub.displayImage = defaultSublocationSprite; } }//else, no displayImage is needed, since won't show on map } } mapLoaderDone = true; Debug.Log("MapLoader ready"); }
public void SublocationFactory_Civic() { Sublocation sl = SubLocationFactory.CreateSubLocation(Civic.TYPE, 1, 1, 1); Assert.IsInstanceOfType(sl, typeof(Civic)); }
public void SublocationFactory_Commercial() { Sublocation sl = SubLocationFactory.CreateSubLocation(Commercial.TYPE, 1, 1, 1); Assert.IsInstanceOfType(sl, typeof(Commercial)); }
public void SublocationFactory_Residential() { Sublocation sl = SubLocationFactory.CreateSubLocation(Residential.TYPE, 1, 1, 1); Assert.IsInstanceOfType(sl, typeof(Residential)); }