Ejemplo n.º 1
0
        public void AdminAddNewsItem(AddNewsItemViewModel model)
        {
            news newNewsItem = new news()
            {
                active = model.Active,
                body = model.Body,
                created_date = DateTime.Now,
                creator_id = model.CreatorID,
                image = model.ImageFilePath,
                title = model.Title
            };
            _dbContext.news.Add(newNewsItem);

            Save();
        }
Ejemplo n.º 2
0
        public ActionResult AddNewsItem(AddNewsItemViewModel model)
        {
            model.CreatorID = WebSecurity.CurrentUserId;

            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Image != null)
                    {
                        Utilities.JPPDirectory.CheckAndCreateNewsDirectory(Server);
                        model.ImageFilePath = Utilities.JPPDirectory.CreateFilePath(JPPDirectory.ImageTypes.News);
                        Utilities.JPPImage.Save(Server, model.ImageFilePath, model.Image.InputStream, JPPConstants.Images.NewsImageMaxSize, 200, true);
                    }

                    UnitOfWork work = new UnitOfWork();
                    work.SystemRepository.AdminAddNewsItem(model);
                    return RedirectToAction("Index");
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "News Item Failed to Add: " + e.Message);
                }
            }

            return View(model);
        }
Ejemplo n.º 3
0
 public ActionResult AddNewsItem()
 {
     AddNewsItemViewModel model = new AddNewsItemViewModel();
     return View(model);
 }