public async Task <ActionResult> Edit([Bind(Include = "MeshId,Name,CustValue,Yeild,Sublimation,MeasureId,ColorMeshId,DataCreate")] Mesh mesh) { if (ModelState.IsValid) { try{ db.Entry(mesh).State = EntityState.Modified; await db.SaveChangesAsync(); } catch (System.Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.Contains("Mesh_Name_Index")) { ModelState.AddModelError(string.Empty, "Não é possível inserir com o mesmo nome!"); } else { ModelState.AddModelError(string.Empty, ex.Message); } ViewBag.MeasureId = new SelectList(CombosHelper.GetMeasures(), "MeasureId", "Name", mesh.MeasureId); ViewBag.ColorMeshId = new SelectList(CombosHelper.GetColors(), "ColorMeshId", "Color", mesh.ColorMeshId); return(View(mesh)); } } ViewBag.ColorMeshId = new SelectList(CombosHelper.GetColors(), "ColorMeshId", "Color", mesh.ColorMeshId); ViewBag.MeasureId = new SelectList(CombosHelper.GetMeasures(), "MeasureId", "Name", mesh.MeasureId); return(View(mesh)); }
public async Task <ActionResult> Edit([Bind(Include = "TechnicalPrintId,Name,CustValue")] TechnicalPrint technicalPrint) { if (ModelState.IsValid) { try{ db.Entry(technicalPrint).State = EntityState.Modified; await db.SaveChangesAsync(); } catch (System.Exception) { ModelState.AddModelError(string.Empty, "Não possível adicionar, por ter um item cadastrado com esse mesmo nome!"); return(View(technicalPrint)); throw; } return(RedirectToAction("Index")); } return(View(technicalPrint)); }
public async Task <ActionResult> Edit([Bind(Include = "ColorMeshId,Color,DataCreate")] ColorMesh colorMesh) { if (ModelState.IsValid) { try{ db.Entry(colorMesh).State = EntityState.Modified; await db.SaveChangesAsync(); } catch (System.Exception) { ModelState.AddModelError(string.Empty, "Não possível adicionar, por ter um item cadastrado com esse mesmo nome!"); return(View(colorMesh)); throw; } return(RedirectToAction("Index")); } return(View(colorMesh)); }
public ActionResult Edit([Bind(Include = "DepartmentId,Name")] Department department) { if (ModelState.IsValid) { try { db.Entry(department).State = EntityState.Modified; db.SaveChanges(); } catch (System.Exception) { ModelState.AddModelError(string.Empty, "Não possível adicionar, por ter um item cadastrado com esse mesmo nome!"); return(View(department)); throw; } return(RedirectToAction("Index")); } return(View(department)); }
public async Task <ActionResult> Edit([Bind(Include = "PersonId,FirstName,LastName,Email,Photo,Gnere,TypePerson,CpfOrCnpj,DateBirth,AvailableCredit,StatusClient")] Client client) { if (ModelState.IsValid) { try { db.Entry(client).State = EntityState.Modified; await db.SaveChangesAsync(); } catch (System.Exception) { ModelState.AddModelError(string.Empty, "Não possível adicionar, por ter um item cadastrado com esse mesmo nome!"); return(View(client)); throw; } return(RedirectToAction("Index")); } return(View(client)); }
public async Task <ActionResult> Edit([Bind(Include = "PrintSizeId,Name,SizeX,SizeY,ValueSize,MeasureId,DataCreate")] PrintSize printSize) { if (ModelState.IsValid) { try { db.Entry(printSize).State = EntityState.Modified; await db.SaveChangesAsync(); } catch (System.Exception) { ModelState.AddModelError(string.Empty, "Não possível adicionar, por ter um item cadastrado com esse mesmo nome!"); return(View(printSize)); throw; } return(RedirectToAction("Index")); } ViewBag.MeasureId = new SelectList(db.Measures, "MeasureId", "Name", printSize.MeasureId); return(View(printSize)); }