Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
 public Photo Update(Photo p)
 {
     _db.Entry(p).State = System.Data.EntityState.Modified;
     _db.SaveChanges();
     return p;
 }
Ejemplo n.º 3
0
 public Photo Add(Photo p)
 {
     this._db.Photos.Add(p);
     this._db.SaveChanges();
     return p;
 }