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

            Problem problem = new Problem {
                Name = model.Name, Points = model.Points
            };

            problemsService.Create(problem);

            return(Redirect("/"));
        }
Beispiel #2
0
        public HttpResponse Create(string name, int points)
        {
            if (string.IsNullOrEmpty(name) || name.Length < 5 || name.Length > 20)
            {
                return(Error("Name should be between 5 and 20 characters."));
            }

            if (points < 50 || points > 300)
            {
                return(Error("Points should be between 50 and 300."));
            }

            problemsService.Create(name, (ushort)points);
            return(Redirect("/"));
        }