public List <int> VerifyHamlet() { var errors = new List <int>(); if (Hamlet == null) { return(errors); } Hamlet = Hamlet.Trim().Replace(HidroConstants.DOUBLE_SPACE, HidroConstants.WHITE_SPACE); if (string.IsNullOrWhiteSpace(Hamlet)) { Hamlet = null; return(errors); } Hamlet = HelperProvider.CapitalizeFirstLetterOfEachWord(Hamlet); var lenTest = new Regex(@".{1,40}"); if (!lenTest.IsMatch(Hamlet)) { errors.Add(27); } var rx = new Regex(@"^[A-Za-z\d ]*$"); if (!rx.IsMatch(Hamlet)) { errors.Add(28); } return(errors); }
public ActionResult DeleteConfirmed(int id) { Hamlet hamlet = db.Hamlets.Find(id); db.Hamlets.Remove(hamlet); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Generates a single Hamlet. /// </summary> /// <returns></returns> public IPopulationCenters GenerateSingle(ICivilization civilization) { IPopulationCenters center = null; if (!civilization.RegionsOwned.Last().CanSupportAdditionalPopulationCenters()) return center; // as long as the last region has available centers we can keep going center = new Hamlet(); // we start with a hamlet and move up as population increases return CreateCenter(civilization, center); }
// GET: Hamlet/Edit/5 public ActionResult Edit(int?id) { var user = UserManager.FindById(User.Identity.GetUserId()); var UsrLang = user.Institution.Country.Language; //**** var cat_countries = from c in db.Countries select c; if (user.Institution.AccessLevel == AccessLevel.Country || user.Institution.AccessLevel == AccessLevel.SelfOnly || user.Institution.AccessLevel == AccessLevel.Service) { if (user.Institution.AccessLevel == AccessLevel.Country) { cat_countries = cat_countries.Where(s => s.ID == user.Institution.CountryID); } else if (user.Institution.AccessLevel == AccessLevel.SelfOnly || user.Institution.AccessLevel == AccessLevel.Service) { cat_countries = cat_countries.Where(s => s.ID == user.Institution.CountryID); } } ViewBag.Countries = new SelectList(cat_countries, "ID", "Name"); //**** var cat_areas = db.Areas.Include(a => a.Country); if (user.Institution.AccessLevel == AccessLevel.Country || user.Institution.AccessLevel == AccessLevel.SelfOnly || user.Institution.AccessLevel == AccessLevel.Service) { if (user.Institution.AccessLevel == AccessLevel.Country) { cat_areas = cat_areas.Where(s => s.CountryID == user.Institution.CountryID) .OrderBy(o => o.Country.Name).ThenBy(o => o.Name); } else if (user.Institution.AccessLevel == AccessLevel.SelfOnly || user.Institution.AccessLevel == AccessLevel.Service) { cat_areas = cat_areas.Where(s => s.CountryID == user.Institution.CountryID) .OrderBy(o => o.Country.Name).ThenBy(o => o.Name); } } ViewBag.Areas = new SelectList(cat_areas, "ID", "Name"); //**** if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Hamlet hamlet = db.Hamlets.Find(id); if (hamlet == null) { return(HttpNotFound()); } return(View(hamlet)); }
public ActionResult Edit([Bind(Include = "ID, NeighborhoodID, Name, orig_country")] Hamlet hamlet) { if (ModelState.IsValid) { db.Entry(hamlet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.CountryID = new SelectList(db.Countries, "ID", "Code", area.CountryID); //?????? return(View(hamlet)); }
public ActionResult Create([Bind(Include = "ID, NeighborhoodID, Name, orig_country, Latitude, Longitude")] Hamlet hamlet) { if (ModelState.IsValid) { db.Hamlets.Add(hamlet); db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.CountryID = new SelectList(db.Countries, "ID", "Code", area.CountryID); //??????? return(View(hamlet)); }
// GET: Hamlet/Details public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Hamlet hamlet = db.Hamlets.Find(id); if (hamlet == null) { return(HttpNotFound()); } return(View(hamlet)); }