public ActionResult DeleteConfirmed(int id) { RollingStockType rollingStockType = db.RollingStockTypes.Find(id); db.RollingStockTypes.Remove(rollingStockType); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "RollingStockID,RollingStockName")] RollingStockType rollingStockType) { if (ModelState.IsValid) { db.Entry(rollingStockType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rollingStockType)); }
public ActionResult Create([Bind(Include = "RollingStockID,RollingStockName")] RollingStockType rollingStockType) { if (ModelState.IsValid) { db.RollingStockTypes.Add(rollingStockType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rollingStockType)); }
// GET: RollingStockTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RollingStockType rollingStockType = db.RollingStockTypes.Find(id); if (rollingStockType == null) { return(HttpNotFound()); } return(View(rollingStockType)); }
public async Task <ActionResult <RollingStockTypeModel> > Create(RollingStockTypeModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var rollingStockType = new RollingStockType { Name = model.Name, AARDesignation = model.AARDesignation, Description = model.Description }; await _rollingStockTypeRepository.CreateAsync(rollingStockType); model = _mapper.Map <RollingStockTypeModel>(rollingStockType); return(CreatedAtAction(nameof(GetById), new { id = rollingStockType.Id }, model)); }