Пример #1
0
 public MediaBinding SaveImage(FileRead Model, int SiteID, string UserID)
 {
     if (Model != null)
     {
         using (var _c = db)
         {
             Can(SiteID, UserID, _c);
             var _Media = SaveMedia(null, SiteID);
             var _ContainerReference = _Media.MediaID + "/" + Model.FileName;
             if (new Utils.FileUtil().Exist("media", _ContainerReference))
             {
                 Model.FileName = Utils.Util.RandomString(5) + Model.FileName;
                 _ContainerReference = _Media.MediaID + "/" + Model.FileName;
             }
             new Utils.FileUtil().UploadImage(Utils.ImageUtil.StringToStream(Model.FileContent), "media", _ContainerReference);
             var _FinalURL = StorageUrl + "/media/" + _ContainerReference;
             _Media = _c.Medias.Where(m => m.MediaID == _Media.MediaID).FirstOrDefault();
             _Media.MediaUrl = _FinalURL;
             _c.SaveChanges();
             return new MediaBinding
             {
                 MediaID=_Media.MediaID,
                 SiteID=SiteID,
                 MediaUrl=_Media.MediaUrl
             };
         }
     }
     return null;
 }
Пример #2
0
 public IHttpActionResult Import(FileRead _Model)
 {
     SiteService.Import(_Model);
     return Ok();
 }
Пример #3
0
 public int Import(FileRead _FileRead)
 {
     byte[] binary = Convert.FromBase64String(_FileRead.FileContent.Split(',')[1]);
     return ImportObject(JsonConvert.DeserializeObject<SiteExport>(Encoding.UTF8.GetString(binary)));
 }
Пример #4
0
 private string SaveIcon(int ProductID, int CultureID, FileRead FileReadModel)
 {
     var _Container = "product-icon";
     var _ContainerReference = ProductID + "/" + CultureID + "/" + FileReadModel.FileName;
     new Utils.FileUtil().DeleteFolder(_Container, ProductID + "/" + CultureID + "/");
     new Utils.FileUtil().UploadImage(Utils.ImageUtil.StringToStream(FileReadModel.FileContent), _Container, _ContainerReference);
     return StorageUrl + "/" + _Container + "/" + _ContainerReference;
 }