Esempio n. 1
0
 public void SaveNewsGallery(NewsGallery NewsGallery)
 {
     if (NewsGallery.Id == 0)
     {
         _RNewsGallery.Add(NewsGallery);
     }
     else
     {
         _uow.Entry(NewsGallery).State = EntityState.Modified;
     }
     _uow.SaveChanges();
 }
Esempio 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/NewsGallery/" + 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);

                NewsGallery Item = new NewsGallery();
                Item.Image = e.Param.FileStatusItem.FileName;
                Item.NewsId = FolderId;
                EFDbContext.NewsGalleries.Add(Item);
                EFDbContext.SaveChanges();

            }
            e.Context.PipelineControl.Message.MessageText += string.Format(_logpattern, "log-post", "StoreFileRequestStartedAsync", DateTime.Now.ToLongTimeString());
        }
Esempio n. 3
0
 public void DeleteNewsGallery(NewsGallery NewsGallery)
 {
     _RNewsGallery.Remove(NewsGallery);
     _uow.SaveChanges();
 }