示例#1
0
        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());
        }
示例#2
0
        public ActionResult AddNewReview(Review review)
        {
            if (review.ProfileId == 0)
            {
                review.ProfileId = 1;
            }
            var db = new ReviewerContext();

            db.Review.Add(review);
            db.SaveChanges();


            return(View());
        }