Example #1
0
        public ActionResult Index(AddIndexViewModel viewModel)
        {
            var userRole = GetUserRole();

            if (userRole != "Admin" && userRole != "Creator")
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }

            var newChallengeBooks = new List <int>();

            foreach (var book in viewModel.ChallengeBooks)
            {
                if (book != 0)
                {
                    newChallengeBooks.Add(book);
                }
            }

            viewModel.ChallengeBooks = newChallengeBooks;

            if (viewModel.ChallengeBooks.Count() < 1)
            {
                ModelState.AddModelError("No Books", "A challenge must have at least 1 book.");
            }

            if (!ModelState.IsValid)
            {
                viewModel.Init(_bookRepository);
                return(View(viewModel));
            }

            _challengeRepository.Add(viewModel.Challenge, viewModel.ChallengeBooks);
            return(RedirectToAction("Index", "Home"));
        }
 public ApplicationViewModel(Entities.Application applicaiton)
 {
     ApplicationId     = applicaiton.Id;
     Code              = applicaiton.Code;
     Description       = applicaiton.Description;
     AddIndexViewModel = new AddIndexViewModel(applicaiton.Id);
     foreach (Entities.IndexDefinition indexDefinition in applicaiton.IndexDefinitions)
     {
         var ivm = new IndexViewModel(indexDefinition);
         AddIndexViewModel.AddIndex(ivm);
     }
 }
Example #3
0
 public virtual ActionResult Create(AddIndexViewModel indexViewModel)
 {
     if (ModelState.IsValid)
     {
         _applicationService.AddIndex(indexViewModel.ApplicaitonId, indexViewModel.Name, indexViewModel.ArchiveName, indexViewModel.ArchiveColumn);
     }
     else
     {
         TempData["comment"] = "Required files are missing";
     }
     return(new RedirectResult(Request.Headers["Referer"]));
 }
Example #4
0
        // GET: Add
        public ActionResult Index()
        {
            var userRole = GetUserRole();

            if (userRole != "Admin" && userRole != "Creator")
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }
            var viewModel = new AddIndexViewModel();

            viewModel.Init(_bookRepository);
            return(View(viewModel));
        }