public ActionResult Create([Bind(Include = "Id,IdModel,Libelle,Valeur,Ordre")] ItemsFormViewModel gEN_ItemsView) { ItemsPivot gEN_Devises = Mapper.Map <ItemsFormViewModel, ItemsPivot>(gEN_ItemsView); if (ModelState.IsValid) { if (gEN_Devises.Id > 0) { itemsServise.UpdateItemsPivot(gEN_Devises); // db.Entry(gEN_Items).State = EntityState.Modified; itemsServise.SaveItemsPivot(); // db.SaveChanges(); return(RedirectToAction("Index")); } else { // db.GEN_Items.Add(gEN_Items); //db.SaveChanges(); itemsServise.CreateItemsPivot(gEN_Devises); itemsServise.SaveItemsPivot(); return(RedirectToAction("Index")); } } ViewBag.IdModel = new SelectList(modelsService.GetModels(), "Id", "Model", gEN_Devises.IdModel); return(View(gEN_ItemsView)); }