示例#1
0
        public async Task <ActionResult> Add(DisplayPhoto displayPhoto, HttpPostedFileBase file)
        {
            if (file != null)
            {
                displayPhoto.RawData = new byte[file.ContentLength];

                file.InputStream.Read(displayPhoto.RawData, 0, file.ContentLength);
            }

            Photo photo = new Photo
            {
                Id      = displayPhoto.Identifier,
                Name    = displayPhoto.Name,
                Type    = displayPhoto.Type,
                AlbumId = displayPhoto.AlbumId,
                Size    = displayPhoto.Size,
                RawData = displayPhoto.RawData
            };

            await PhotoService.AddAsync(photo);

            return(RedirectPermanent("Photos"));
        }