コード例 #1
0
        public IActionResult Post([FromBody] TeamCategoryViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var newCategory = new TeamCategory()
                    {
                        Name = model.Name
                    };

                    repository.AddTeamCategory(newCategory);
                    if (repository.SaveAll())
                    {
                        return(Ok("New team category has been saved"));
                    }
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
            return(BadRequest("Failed to save new team category"));
        }
コード例 #2
0
ファイル: Group.cs プロジェクト: yang-er/OnlineJudge
 public Group(TeamCategory c)
 {
     hidden    = !c.IsPublic;
     color     = c.Color;
     icpc_id   = "cat" + c.CategoryId;
     id        = $"{c.CategoryId}";
     name      = c.Name;
     sortorder = c.SortOrder;
 }
コード例 #3
0
 public void AddTeamCategory(TeamCategory teamCategory)
 {
     AddEntity(teamCategory);
 }