public ActionResult Create(workingDay workingDays) { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Photos"; if (workingDays.PhotoFile != null) { pic = FilesHelper.UploadPhoto(workingDays.PhotoFile, folder); pic = string.Format("{0}/{1}", folder, pic); } workingDays.image = pic; db.workingDays.Add(workingDays); db.workingDays.Add(workingDays); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(workingDays)); }
// GET: workingDays/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } workingDay workingDay = db.workingDays.Find(id); if (workingDay == null) { return(HttpNotFound()); } return(View(workingDay)); }
public ActionResult Edit(workingDay workingDays) { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Photos"; if (workingDays.PhotoFile != null) { pic = FilesHelper.UploadPhoto(workingDays.PhotoFile, folder); pic = string.Format("{0}/{1}", folder, pic); workingDays.image = pic; } db.Entry(workingDays).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } if (ModelState.IsValid) { } return(View(workingDays)); }