Advertisement
ilche_i

Untitled

Aug 31st, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. public ActionResult SaveGroupImage(long groupId)
  2.         {
  3.             var group = RepositoryContext.DataRepository.Get<Group>(groupId, "VisualDetail");
  4.  
  5.             var file = Request.Files["ImageData"];
  6.             using (var binaryReader = new BinaryReader(file.InputStream))
  7.             {
  8.                 var fileData = binaryReader.ReadBytes(file.ContentLength);
  9.  
  10.                 if (group.VisualDetail == null)
  11.                 {
  12.                     GroupVisualDetail gvd = new GroupVisualDetail
  13.                     {
  14.                         ID = groupId,
  15.                         ImageData = fileData,
  16.                         ImageType = file.ContentType
  17.                     };
  18.                     RepositoryContext.DataRepository.Insert(gvd);
  19.                 }
  20.                 else
  21.                 {
  22.                     group.VisualDetail.ImageData = fileData;
  23.                     group.VisualDetail.ImageType = file.ContentType;
  24.                     RepositoryContext.DataRepository.Save();
  25.                 }
  26.             }
  27.             return new EmptyResult();
  28.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement