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"));
        }
Beispiel #2
0
 public Group(TeamCategory c)
 {
     hidden    = !c.IsPublic;
     color     = c.Color;
     icpc_id   = "cat" + c.CategoryId;
     id        = $"{c.CategoryId}";
     name      = c.Name;
     sortorder = c.SortOrder;
 }
Beispiel #3
0
 public void AddTeamCategory(TeamCategory teamCategory)
 {
     AddEntity(teamCategory);
 }