Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult SaveGroupImage(long groupId)
- {
- var group = RepositoryContext.DataRepository.Get<Group>(groupId, "VisualDetail");
- var file = Request.Files["ImageData"];
- using (var binaryReader = new BinaryReader(file.InputStream))
- {
- var fileData = binaryReader.ReadBytes(file.ContentLength);
- if (group.VisualDetail == null)
- {
- GroupVisualDetail gvd = new GroupVisualDetail
- {
- ID = groupId,
- ImageData = fileData,
- ImageType = file.ContentType
- };
- RepositoryContext.DataRepository.Insert(gvd);
- }
- else
- {
- group.VisualDetail.ImageData = fileData;
- group.VisualDetail.ImageType = file.ContentType;
- RepositoryContext.DataRepository.Save();
- }
- }
- return new EmptyResult();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement