Пример #1
0
 protected TeamObject(TeamObject copy)
     : base(copy)
 {
     Name = copy.Name;
     MapId = copy.MapId;
     PrimaryColor = copy.PrimaryColor;
     SecondaryColor = copy.SecondaryColor;
     points = ((MapComponentCollection<MapPoint>)copy.Points).Clone();
 }
Пример #2
0
 public Team(TeamObject team)
     : base(team)
 {
     // do nothing
 }
        public HttpResponseMessage PutTeam(TeamObject team)
        {
            HttpResponseMessage response;

            // remote write enabled
            if (Minimap.TEAMS_ALLOW_REMOTE_WRITE)
            {
                // team found
                if (team != null && Minimap.TeamManager().Get(team.Id) != null)
                {
                    // add successful
                    if (Minimap.TeamManager().Add(team))
                    {
                        response = Request.CreateResponse(HttpStatusCode.OK);
                    }

                    // add failed
                    else
                    {
                        response = Request.CreateResponse(HttpStatusCode.NotAcceptable);
                    }
                }

                // team not found
                else
                {
                    response = PostTeam(team);
                }
            }

            // remote write disabled
            else
            {
                response = Request.CreateResponse(HttpStatusCode.Forbidden);
            }

            return response;
        }
        public HttpResponseMessage PostTeam(TeamObject team)
        {
            HttpResponseMessage response;

            // remote write enabled
            if (Minimap.TEAMS_ALLOW_REMOTE_WRITE)
            {
                // add successful
                if (Minimap.TeamManager().Add(team))
                {
                    response = Request.CreateResponse<TeamObject>(HttpStatusCode.Created, team);

                    // include resource location in response header
                    string uri = Url.Link("DefaultApi", new { id = team.Id });
                    response.Headers.Location = new Uri(uri);
                }

                // add failed
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.NotAcceptable);
                }
            }

            // remote write disabled
            else
            {
                response = Request.CreateResponse(HttpStatusCode.Forbidden);
            }

            return response;
        }