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

            this.problemService.CreateProblem(model.Name, model.Points);
            return(this.Redirect("/"));
        }
Exemple #2
0
        public IActionResult Create(CreateProblemInputModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                return(this.Redirect("/Problems/Create"));
            }

            this.problemService.AddNewProblemToDb(inputModel.Name, inputModel.Points);

            return(this.Redirect("/"));
        }
Exemple #3
0
        public IActionResult Create(CreateProblemInputModel createProblem)
        {
            if (!ModelState.IsValid)
            {
                return(this.Redirect("/"));
            }

            this.problemsServices.CreateProblem(createProblem.Name, createProblem.Points);

            return(this.Redirect("/"));
        }
Exemple #4
0
        public void CreateProblem(CreateProblemInputModel model)
        {
            var problem = new Problem
            {
                Name   = model.Name,
                Points = (ushort)model.Points
            };

            this.db.Problems.Add(problem);
            this.db.SaveChanges();
        }
Exemple #5
0
        public void Create(CreateProblemInputModel inputModel)
        {
            var problem = new Problem
            {
                Name   = inputModel.Name,
                Points = inputModel.Points,
            };

            this.db.Problems.Add(problem);
            this.db.SaveChanges();
        }
Exemple #6
0
        public IActionResult Create(CreateProblemInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.Redirect("/Problems/Create"));
            }

            Problem problem = ModelMapper.ProjectTo <Problem>(input);

            this.problemService.Create(problem);
            return(this.Redirect("/"));
        }
        public HttpResponse Create(CreateProblemInputModel model)
        {
            if (!this.IsUserSignedIn())
            {
                return(this.Redirect("Users/Login"));
            }

            if (string.IsNullOrWhiteSpace(model.Name) || model.Name.Length < 5 || model.Name.Length > 20)
            {
                return(this.Error("Invalid problem name.Problem name should be between 5 and 20 characters."));
            }
            if (model.Points < 50 || model.Points > 300)
            {
                return(this.Error("Invalid problem points.Problem points should be between 50 and 300."));
            }

            this.problemService.CreateProblem(model);
            return(this.Redirect("/"));
        }
        public HttpResponse Create(CreateProblemInputModel inputModel)
        {
            if (!this.IsUserSignedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            if (string.IsNullOrWhiteSpace(inputModel.Name) || inputModel.Name.Length < 5 || inputModel.Name.Length > 20)
            {
                return(this.Error("Problem's name should be between 5 and 20 characters long."));
            }

            if (inputModel.Points < 50 || inputModel.Points > 300)
            {
                return(this.Error("Points should be in range 50 - 300"));
            }

            this.problemsService.Create(inputModel);
            return(this.Redirect("/"));
        }
        public HttpResponse Create(CreateProblemInputModel input)
        {
            if (!this.IsUserSignedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            if (string.IsNullOrWhiteSpace(input.Name) || input.Name.Length < 5 || input.Name.Length > 20)
            {
                return(this.Redirect("/Problems/Create"));
            }

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

            this.problemsService.CreateProblem(input.Name, input.Points);

            return(this.Redirect("/"));
        }
Exemple #10
0
        public HttpResponse Create(CreateProblemInputModel input)
        {
            if (!this.IsUserLoggedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            //Validate input

            if (input.Name.Length < 5 || input.Name.Length > 20)
            {
                return(this.Error("Name must be between 5 and 20 characters."));
            }

            if (input.Points < 50 || input.Points > 300)
            {
                return(this.Error("Points must be between 50 and 300."));
            }

            this.problemsService.Create(input.Name, input.Points);
            return(this.Redirect("/"));
        }