public IActionResult Save(string id, string jsonString)
        {
            JObject obj = JObject.Parse(jsonString);
            string newID = obj["name"].Value<string>();
            Group group;
            if (id == null)
            {
                group = new Group(newID, MasterController.Instance.Groups.Count + 1);
            }
            else if (MasterController.Instance.Groups.ContainsKey(id))
            {
                MasterController.Instance.Groups.TryRemove(id, out group);
                group.Name = newID;
            }
            else
            {
                Response.StatusCode = 404;
                return new EmptyResult();
            }
            
            if(MasterController.Instance.Groups.TryAdd(newID, group))
            {
                FileAccess.SaveGroups();
                if (MasterController.Instance.Venue != null)
                {
                    FileAccess.SaveVenue(MasterController.Instance.Venue.Serialize());
                }
                FileAccess.RenameGroup(id, newID);

                Response.StatusCode = 200;
                return new EmptyResult();
            }
            else
            {
                Response.StatusCode = 500;
                return new EmptyResult();
            }
        }
Пример #2
0
 public static Group GetGroup()
 {
     Group group = new Group("TestGroup", 1);
     return group;
 }