Пример #1
0
        public ActionResult GetPhoto(int ItemId, int Id, bool IsHead, HttpPostedFileBase Image)
        {
            Image img = new Image()
            {
                Id            = Id,
                ItemId        = ItemId,
                IsHead        = IsHead,
                ImageMimeType = Image.ContentType,
                ImageData     = new byte[Image.ContentLength]
            };

            Image.InputStream.Read(img.ImageData, 0, Image.ContentLength);

            _repo.AddImg(img);

            Models.Image newImg = Id == 0 ? _repo.Images.Last() : _repo.Images.First(x => x.Id == Id);

            TempData["message"] = string.Format("Изменения в товаре \"{0}\" были сохранены", _repo.Items.First(x => x.Id == ItemId).Name);
            return(View("AddPhoto", newImg));
        }