Пример #1
0
 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
 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();
     }
 }