public GeoDivision GetBasedOnLang(GeoDivision geoDivision) { if (_currentLang != 1) { geoDivision.Title = geoDivision.LatinTitle; } return(geoDivision); }
public ActionResult Edit(GeoDivision geoDivision) { if (ModelState.IsValid) { _geoDivisionRepo.Update(geoDivision); return(RedirectToAction("Index", new { parentId = geoDivision.ParentId })); } return(View(geoDivision)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GeoDivision geoDivision = _geoDivisionRepo.Get(id.Value); if (geoDivision == null) { return(HttpNotFound()); } return(PartialView(geoDivision)); }
public ActionResult Create(GeoDivision geoDivision) { geoDivision.GeoDivisionType = 0; geoDivision.IsArchived = 0; if (ModelState.IsValid) { if (geoDivision.ParentId != null) { var parent = _geoDivisionRepo.Get(geoDivision.ParentId.Value); geoDivision.GeoDivisionType = parent.GeoDivisionType + 1; } _geoDivisionRepo.Add(geoDivision); return(RedirectToAction("Index", new { parentId = geoDivision.ParentId })); } return(View(geoDivision)); }
public string GetLocationStr(int child) { var geoList = new List <string>(); var geo = new GeoDivision(); int?id = child; do { geo = _context.GeoDivisions.FirstOrDefault(g => g.IsDeleted == false && g.Id == id); if (geo != null) { geoList.Add(_currentLang == (int)Language.Farsi ? geo.Title : geo.LatinTitle); id = geo.ParentId; } } while (id != null); geoList.Reverse(); return(string.Join(", ", geoList)); }