public ActionResult Edit(ArticleItem model)
        {
            _repository.LangId = CurrentLangId;
            var articleItem = _repository.GetArticleItem(model.Id);

            articleItem.Text = model.Text == null ? "" : HttpUtility.HtmlDecode(model.Text);

            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];
                if (file == null) continue;
                if (string.IsNullOrEmpty(file.FileName)) continue;

                string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                string filePath = Server.MapPath("~/Content/Images");

                filePath = Path.Combine(filePath, fileName);
                GraphicsHelper.SaveOriginalImage(filePath, fileName, file, 1500);
                var articleItemImage = new ArticleItemImage() { ImageSource = fileName };
                articleItem.ArticleItemImages.Add(articleItemImage);
            }


            _repository.SaveArticleItem(articleItem);
            return RedirectToAction("Details", "Article", new { id = articleItem.Article.Id });
        }
Beispiel #2
0
 public int AddArticleItem(ArticleItem articleItem)
 {
     _store.ArticleItems.Add(articleItem);
     CreateOrChangeEntityLanguage(articleItem);
     _store.SaveChanges();
     return articleItem.Id;
 }
Beispiel #3
0
        private void CreateOrChangeEntityLanguage(ArticleItem cache)
        {
            var categoryLang = _store.ArticleItemLangs.FirstOrDefault(r => r.ArticleItemId == cache.Id && r.LanguageId == LangId);
            if (categoryLang == null)
            {
                var entityLang = new ArticleItemLang
                {
                    ArticleItemId = cache.Id,
                    LanguageId = LangId,

                    Text = cache.Text,
                };
                _store.ArticleItemLangs.Add(entityLang);
            }
            else
            {
                categoryLang.Text = cache.Text;
            }

        }
Beispiel #4
0
 public void SaveArticleItem(ArticleItem articleItem)
 {
     var cache = _store.ArticleItems.Single(c => c.Id == articleItem.Id);
     CreateOrChangeEntityLanguage(cache);
     _store.SaveChanges();
 }