Ejemplo n.º 1
0
        public ActionResult Edit(int? id, string Title, string Description, DateTime DateTime, bool Live, HttpPostedFileBase[] Photos)
        {
            ArticleBl art = new ArticleBl();
            int _id = id != null ? int.Parse(id.ToString()) : 0;
            Article _art = art.Save(_id, Title, Description, DateTime, Live);

            if (Photos != null)
            {
                foreach (HttpPostedFileBase file in Photos)
                {
                    if (file != null)
                    {
                        string ogFilePath = System.IO.Path.Combine(Server.MapPath(ImageFiles.SaveFilePath(Article.FolderPath)));
                        file.SaveAs(ogFilePath);

                        string filePath = ImageFiles.Resize(1000, 1000, ogFilePath, Article.FolderPath);
                        string previewPath = ImageFiles.Resize(500, 500, ogFilePath, Article.FolderPath);
                        string thumbPath = ImageFiles.Crop(100, 100, ogFilePath, Article.FolderPath);
                        string iconPath = ImageFiles.Crop(50, 50, ogFilePath, Article.FolderPath);

                        PhotoBl photo = new PhotoBl();
                        photo.Save(0, _art.Id, PhotoType.Article, filePath, previewPath, thumbPath, iconPath);

                        //delete og file path when done in case its too big
                        System.IO.File.Delete(ogFilePath);
                    }

                }
            }

            return RedirectToAction("edit", "article", new { id = _art.Id });
        }
Ejemplo n.º 2
0
 public ActionResult Delete(int? id)
 {
     ArticleBl work = new ArticleBl();
     if (id != null)
     {
         work.Delete(int.Parse(id.ToString()));
     }
     return RedirectToAction("index");
 }