public IActionResult Create(ProblemCreateBindingModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.Redirect("/Problems/Create"));
            }

            var problem = ModelMapper.ProjectTo <Problem>(model);

            this.problemService.CreateProblem(problem);

            return(this.Redirect("/"));
        }
示例#2
0
        public IActionResult Create(ProblemCreateBindingModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View());
            }

            Problem problem = this.problemsService.CreateProblem(model.To <Problem>());

            this.usersService.AddProblemToItsCreator(problem.Id, this.User.Id);

            return(this.Redirect("/"));
        }
        public HttpResponse Create(ProblemCreateBindingModel model)
        {
            if (!this.IsUserLoggedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            if (string.IsNullOrWhiteSpace(model.Name) ||
                model.Points < 50 ||
                model.Points > 300)
            {
                return(this.Redirect("/Problems/Create"));
            }

            this.problemService.CreateProblem(model.Name, model.Points);

            return(this.Redirect("/"));
        }