// // GET: /Machine/Edit/5 public ActionResult Edit(String pCode) { Machine machine = DataManager.ListeMachines.Find(item => item.Code == pCode); MachineViewModel model = new MachineViewModel(); model.LaMachine = machine; model.OldCode = machine.Code; return View(model); }
public ActionResult Edit(MachineViewModel model) { try { string test = "test"; foreach (string inputTagName in Request.Files) { HttpPostedFileBase file = Request.Files[inputTagName]; byte[] buffer = new byte[file.ContentLength]; file.InputStream.Read(buffer, 0, file.ContentLength); model.LaMachine.Logo = buffer; } if (Session["ContentStreamLogo"] != null) { model.LaMachine.Logo = (byte[])Session["ContentStreamLogo"]; } if (Session["ContentStreamMachine"] != null) { model.LaMachine.Photo = (byte[])Session["ContentStreamMachine"]; } GestionnaireMachines gestionnaireMachines = new GestionnaireMachines(); DataManager.ListeMachines = gestionnaireMachines.MettreAJourMachine(model.LaMachine, model.OldCode); return RedirectToAction("Index"); } catch (Exception ex) { HandleErrorInfo error = new HandleErrorInfo(ex, "Machine", "Edit"); return View("Error", error); } }
public ActionResult Upload(HttpPostedFileBase file, MachineViewModel model) { if (file != null && file.ContentLength > 0) { Session["ContentLengthMachine"] = file.ContentLength; Session["ContentTypeMachine"] = file.ContentType; byte[] b = new byte[file.ContentLength]; file.InputStream.Read(b, 0, file.ContentLength); Session["ContentStreamMachine"] = b; } return RedirectToAction("Edit", new { pCode = model.LaMachine.Code }); }