public ActionResult ShowAlbums() { using (var db = new ReviewerContext()) { return View(db.Album.ToList()); } }
public ActionResult Index() { ViewBag.Message = "Reviews List"; var db = new ReviewerContext(); IEnumerable<Review> model = db.Review; return View(model); }
public ActionResult AddNewAlbum(Album data, HttpPostedFileBase image) { using (var db = new ReviewerContext()) { if (image != null) { var binaryReader = new BinaryReader(image.InputStream); var img = new Cover(); img.Image = binaryReader.ReadBytes(image.ContentLength); img.Name = image.ContentType; db.Cover.Add(img); } else { var img = new Cover(); img.Image = null; img.Name = null; db.Cover.Add(img); } db.Album.Add(data); db.SaveChanges(); } return View(); }
public ActionResult Index() { using(var db = new ReviewerContext()) { return View(db.Review.ToList()); } }
public ActionResult AddNewReview(Review review) { if (review.ProfileId == 0) { review.ProfileId = 1; } var db = new ReviewerContext(); db.Review.Add(review); db.SaveChanges(); return View(); }
public FileContentResult GetImage(int coverId) { var db = new ReviewerContext(); Cover cover = db.Cover.FirstOrDefault(p => p.Id == coverId); if (cover != null) { return new FileContentResult(cover.Image, cover.Name); } else { return null; //we need to implement default image with "NO COVER YET" or sth like that. } }