Example #1
0
        public ActionResult Create(NewsEditModel model)
        {
            if (!User.IsTeamIdValidForUser(model.Team.TeamId))
            {
                return HttpNotFound();
            }

            var newsItem = Mapper.Map<NewsItem>(model);
            DbContext.NewsItems.Add(newsItem);
            DbContext.SaveChanges(User.Identity.GetUserId());

            return Redirect(model.UrlForReturn);
        }
Example #2
0
        public ActionResult Create()
        {
            var model = new NewsEditModel
                        {
                            IsActive = true,
                            StartDate = CentralTimeZone.Now,
                            EndDate = CentralTimeZone.Today.AddDays(14),
                            Team = new NewsEditTeamModel {Teams = GetTeams(Consts.CurrentYear)}
                        };

            if (model.Team.Teams.Count == 1)
            {
                model.Team.TeamId = model.Team.Teams[0].TeamId;
            }

            return View("Edit", model);
        }
Example #3
0
        public ActionResult Edit(int id, NewsEditModel model)
        {
            var newsItem = DbContext.NewsItems.SingleOrDefault(n => n.NewsItemId == id);
            if (newsItem == null || !User.IsTeamIdValidForUser(model.Team.TeamId))
            {
                return HttpNotFound();
            }

            Mapper.Map(model, newsItem);
            DbContext.SaveChanges(User.Identity.GetUserId());

            return Redirect(model.UrlForReturn);
        }