public ActionResult SaveImage(HttpPostedFileBase image)
        {
            if (image != null)
            {
                Binary imageBinary = image.GetFileBinary();
                if (imageBinary != null && !string.IsNullOrEmpty(image.ContentType))
                {
                    var imageId = this.repository.AddImage(new Image
                    {
                        Image1           = imageBinary,
                        ImageContentType = image.ContentType
                    });

                    return(this.Json(new { ImageId = imageId.ToString() }));
                }
            }

            return(this.HttpNotFound());
        }
        public ActionResult AddAttachment(HttpPostedFileBase attachment)
        {
            Binary pageAttachment = attachment.GetFileBinary();

            if (attachment != null)
            {
                var id = this.repository.AddAttachment(new Attachment
                {
                    Content       = pageAttachment,
                    ContentLength = attachment.ContentLength,
                    ContentType   = attachment.ContentType,
                    Name          = attachment.FileName,
                    UploadedAt    = DateTime.Now
                });

                return(this.Json(new { Id = id }));
            }

            return(this.HttpNotFound());
        }