public ActionResult Create(Client client) { if (ModelState.IsValid) { var image = WebImage.GetImageFromRequest("UploadedImage"); if (image != null) client.MainImage = Server.MapPath("/Images/Clients/").SaveImage(image); client.Date_Creation = DateTime.Now; context.Clients.Add(client); context.SaveChanges(); return RedirectToAction("Index"); } return View(client); }
public ActionResult Edit(Client client) { if (ModelState.IsValid) { var image = WebImage.GetImageFromRequest("UploadedImage"); if (image != null) client.MainImage = Server.MapPath("/Images/Clients/").SaveImage(image); context.Entry(client).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } return View(client); }