public async Task <IActionResult> Create([Bind("Id,Name")] Town town)
        {
            if (ModelState.IsValid)
            {
                await _townRepository.Add(town);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(town));
        }
Exemple #2
0
 public ActionResult Add(TownDTO entity)
 {
     try
     {
         Town t = new Town();
         t.Name   = entity.Name;
         t.CityID = entity.CityID;
         townRepository.Add(t);
         townRepository.Save();
         return(Json(entity, JsonRequestBehavior.DenyGet));
     }
     catch (Exception e)
     {
         return(Json(false, JsonRequestBehavior.DenyGet));
     }
 }