Exemplo n.º 1
0
 public void SaveArticleGallery(ArticleGallery ArticleGallery)
 {
     if (ArticleGallery.Id == 0)
     {
         _RArticleGallery.Add(ArticleGallery);
     }
     else
     {
         _uow.Entry(ArticleGallery).State = EntityState.Modified;
     }
     _uow.SaveChanges();
 }
Exemplo n.º 2
0
        // Begin of core PUT/POST execution method, values can be edited, or request can be aborted
        async Task handler_StoreFileRequestStartedAsync(object sender, Eventing.Args.StoreFileRequestEventArgs e)
        {
            string ExtFile = "";
            int FolderId = 0;
            if (TempData["Folder"] != null)
            {
                FolderId = Convert.ToInt32(TempData["Folder"]);
                TempData["Folder"] = FolderId;
            }
            if (e.Param.FileStatusItem.StorageInfo.FilePath != Server.MapPath("~/Files/ArticleGallery/" + FolderId + "/") 
                + e.Param.FileStatusItem.FileName)
            {
                ExtFile = "ErrorPath";
            }
            //GetFileExtension Ext = new GetFileExtension();
            var extt = Path.GetExtension(e.Param.FileStatusItem.FileName);
            if (extt != ".jpg" && extt != ".png" && extt != ".jpeg" && extt != ".gif")
            {
                ExtFile = "ErrorExt";
            }

            if (ExtFile != "" && ExtFile == "ErrorPath")
            {
                e.Param.FileStatusItem.ErrorMessage = "مسیر فایل اشتباه است .";
                e.Param.FileStatusItem.Success = false;

            }
            if (ExtFile != "" && ExtFile == "ErrorExt")
            {
                e.Param.FileStatusItem.ErrorMessage = "نوع فایل معتبر نیست .";
                e.Param.FileStatusItem.Success = false;
            }
            if (ExtFile == "")
            {
                EFDbContext EFDbContext = new EFDbContext();
                string Filen = e.Param.FileStatusItem.FileName;

                int find = Filen.LastIndexOf(".");
                //var ext = Filen.Substring(find, Filen.Length - find);
                var MainName = Filen.Substring(0, find);
                MainName = ChangeUnKnownCharacters(MainName);
                e.Param.FileStatusItem.FileName = DateTime.Now.Ticks + MainName + extt;
                e.Param.FileStatusItem.UpdateStatus(true);

                ArticleGallery Item = new ArticleGallery();
                Item.Image = e.Param.FileStatusItem.FileName;
                Item.ArticleId = FolderId;
                EFDbContext.ArticleGalleries.Add(Item);
                EFDbContext.SaveChanges();

            }
            e.Context.PipelineControl.Message.MessageText += string.Format(_logpattern, "log-post", "StoreFileRequestStartedAsync", DateTime.Now.ToLongTimeString());
        }
Exemplo n.º 3
0
 public void DeleteArticleGallery(ArticleGallery ArticleGallery)
 {
     _RArticleGallery.Remove(ArticleGallery);
     _uow.SaveChanges();
 }