public ActionResult DeleteConfirmed(int id) { NationalitiesModel nationalitiesModel = nl.find(id); nl.remove(nationalitiesModel); return(RedirectToAction("Index")); }
// GET: Nationalities/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NationalitiesModel nationalitiesModel = nl.find(id); if (nationalitiesModel == null) { return(HttpNotFound()); } return(View(nationalitiesModel)); }
public static Nationalities ModelToEnity(this NationalitiesModel model, bool virtualActive = false) { Nationalities entity = new Nationalities() { CountryName = model.CountryName, Name = model.Name, Id = model.Id }; if (virtualActive) { entity.Customers = model.Customers; } return(entity); }
public ActionResult Create([Bind(Include = "nationalityID, nationalityName")] NationalitiesModel nationalitiesModel) { if (ModelState.IsValid) { if ((nl.db.Nationalities.Any(ac => ac.nationalityName.Equals(nationalitiesModel.nationalityName)))) { //TODO E.g. ModelState.AddModelError return(RedirectToAction("Create")); } nl.create(nationalitiesModel); return(RedirectToAction("Index")); } return(View(nationalitiesModel)); }
public static NationalitiesModel EntityToModel(this Nationalities entity, bool virtualActive = false) { NationalitiesModel model = new NationalitiesModel() { CountryName = entity.CountryName, Name = entity.Name, Id = entity.Id }; if (virtualActive) { model.Customers = entity.Customers; } return(model); }
public ActionResult NationalityEdit(NationalitiesModel nationalitiesModel) { _serviceNationalities.Update(nationalitiesModel.ModelToEnity()); return(RedirectToAction("NationalityEdit")); }
public ActionResult NationalityInsert(NationalitiesModel nationalitiesModel) { _serviceNationalities.Insert(nationalitiesModel.ModelToEnity()); return(RedirectToAction("NationalityList")); }
public void remove(NationalitiesModel nationalitiesModel) { db.Nationalities.Remove(nationalitiesModel); db.SaveChanges(); }
public void edit(NationalitiesModel nationalitiesModel) { db.Entry(nationalitiesModel).State = EntityState.Modified; db.SaveChanges(); }
public void create(NationalitiesModel nationalitiesModel) { db.Nationalities.Add(nationalitiesModel); db.SaveChanges(); }