public ActionResult Create(TransitStationVM v) { tblTransitStationMaster t = new tblTransitStationMaster(); if (ModelState.IsValid) { t.Name = v.Name; t.CountryID = v.CountryID; t.IsActive = v.IsActive; db.tblTransitStationMasters.Add(t); db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully added Transit Station."; return(RedirectToAction("Index")); } return(View()); }
public ActionResult Edit(int id) { tblTransitStationMaster t = (from c in db.tblTransitStationMasters where c.ID == id select c).First(); TransitStationVM v = new TransitStationVM(); ViewBag.Country = db.CountryMasters.ToList(); if (t == null) { return(HttpNotFound()); } else { v.ID = t.ID; v.Name = t.Name; v.CountryID = t.CountryID.Value; v.IsActive = t.IsActive.Value; } return(View(v)); }
public ActionResult Edit(TransitStationVM v) { tblTransitStationMaster t = new tblTransitStationMaster(); if (ModelState.IsValid) { t.ID = v.ID; t.Name = v.Name; t.CountryID = v.CountryID; t.IsActive = v.IsActive; db.Entry(t).State = EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully Updated Transit Station."; return(RedirectToAction("Index")); } return(View(v)); }