public ActionResult Upload(Photo photo, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null && file.ContentLength > 0) { photo.Href = SaveFile(file); photo.ContentLength = file.ContentLength; photo.ContentType = file.ContentType; photo.User = this.User.Identity.Name; photo.DateAdded = DateTime.UtcNow; photo.FileName = file.FileName; _repository.Add(photo); } } else { return View(photo); } return RedirectToAction("Index"); }
public Photo Update(Photo p) { _db.Entry(p).State = System.Data.EntityState.Modified; _db.SaveChanges(); return p; }
public Photo Add(Photo p) { this._db.Photos.Add(p); this._db.SaveChanges(); return p; }