예제 #1
0
        public IActionResult MainAppHomePage()
        {
            var tagline          = _repository.GetHomePageInfo();
            var tagLineViewModel = new TagLineViewModel();

            if (tagline != null)
            {
                tagLineViewModel.Tagline = tagline.TagLine;
                return(View(tagLineViewModel));
            }
            else
            {
                return(View(new TagLineViewModel()));
            }
        }
예제 #2
0
        public IActionResult MainApphomePage(int id, TagLineViewModel tagLineViewModel)
        {
            if (ModelState.IsValid)
            {
                var tag = _context.HomePage.FirstOrDefault();
                if (tag != null)
                {
                    _context.HomePage.Remove(tag);
                }

                // Create new home page object and add the new tagline
                var homePageInfo = new HomePage
                {
                    TagLine = tagLineViewModel.Tagline
                };

                // Save the new tagline to the database and return to the view
                _context.HomePage.Add(homePageInfo);
                _context.SaveChanges();
                TempData["homepageMessage"] = $"{tagLineViewModel.Tagline} has been added as the new tagline.";
                return(View(tagLineViewModel));
            }
            return(View(tagLineViewModel));
        }