public async Task <IActionResult> Create([Bind("Id,LocationName")] Locations locations)
        {
            if (ModelState.IsValid)
            {
                _context.Add(locations);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(locations));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Create([Bind(Include = "ProvinceId,ProvinceCode,ProvinceName")] Province province)
        {
            if (ModelState.IsValid)
            {
                db.Provinces.Add(province);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(province));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Create([Bind(Include = "CityId,Name,Population,ProvinceId")] City city)
        {
            if (ModelState.IsValid)
            {
                db.Cities.Add(city);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ProvinceId = new SelectList(db.Provinces, "ProvinceId", "ProvinceCode", city.ProvinceId);
            return(View(city));
        }
Ejemplo n.º 4
0
 public async Task AddLocation(Location location)
 {
     _context.Location.Add(location);
     await _context.SaveChangesAsync();
 }