コード例 #1
0
ファイル: PictureService.cs プロジェクト: AntonKuzin/Project
 public void CreatePicture(HttpPostedFileBase fileUpload, string name, string description, string userEmail)
 {
     if (_pictureRepository == null)
         throw new NullReferenceException("service");
     // получаем расширение
     var ext = fileUpload.FileName.Substring(fileUpload.FileName.LastIndexOf(".") + 1);
     byte[] fileData;
     using (var binaryReader = new BinaryReader(fileUpload.InputStream))
     {
         fileData = binaryReader.ReadBytes(fileUpload.ContentLength);
     }
     var picture = new BllPicture()
     {
         Name = name,
         Description = description,
         BinaryData = fileData,
         Extension = ext
     };
     _pictureRepository.CreatePicture(picture.ToDalPicture(), userEmail);
     //_uow.Commit();
 }
コード例 #2
0
ファイル: PictureService.cs プロジェクト: AntonKuzin/Project
 public void UpdatePicture(BllPicture picture)
 {
     if (_pictureRepository == null)
         throw new NullReferenceException("service");
     if (picture == null)
         throw new ArgumentNullException("picture_service");
     if (GetCurrentUserId() == picture.UserId)
     {
         _pictureRepository.UpdatePicture(picture.ToDalPicture());
         //_uow.Commit();
     }
 }