예제 #1
0
        public ApiListHeader PostListHeader(ApiListHeader list)
        {
            if (list == null)
            {
                return(list);
            }
            var request = this.PreparePostRequest("ApiLists", "PostListHeader",
                                                  new Dictionary <string, string> {
                { "id", this.Competition.CompId }, { "password", this.Password }
            },
                                                  list);

            return(this.EndProcessJsonRequest <ApiListHeader>(this.BeginProcessRequest(request, null, null)));
        }
        private void FinalizeList(ApiListHeader result)
        {
            if (result == null || string.IsNullOrEmpty(result.Iid))
            {
                return;
            }
            using (var cmd = this.CreateCommand())
            {
                cmd.CommandText = "UPDATE Lists SET " + ServiceHelper.REMOTE_ID_COLUMN + " = @remoteIid, changed = 0, online = 1 where iid = @iid";
                cmd.Parameters.Add("@remoteIid", SqlDbType.VarChar, ServiceHelper.REMOTE_ID_COL_SIZE).Value = result.Iid;
                cmd.Parameters.Add("@iid", SqlDbType.Int).Value = result.SecretaryId;

                cmd.ExecuteNonQuery();
            }
        }
        private ListHeaderModel UpdateListHeader(CompetitionModel comp, ApiListHeader header)
        {
            ListHeaderModel saveList = comp.Lists.FirstOrDefault(l => l.LocalIid == header.Iid);

            if (saveList == null)
            {
                saveList = new ListHeaderModel {
                    LocalIid = header.Iid
                };
                comp.Lists.Add(saveList);
            }
            saveList.BestResultInQf   = header.BestQf;
            saveList.CompetitionRules = header.Rules;
            if (header.GroupId == null)
            {
                saveList.GroupId = null;
            }
            else
            {
                var agr = comp.AgeGroups.FirstOrDefault(g => g.AgeGroupId == header.GroupId.Value);
                if (agr == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                saveList.GroupId = agr.Iid;
            }
            saveList.IidParent       = header.ParentList;
            saveList.LastRefresh     = header.LastRefresh;
            saveList.ListType        = header.ListType;
            saveList.Live            = header.Live;
            saveList.PreviousRoundId = header.PreviousRound;
            saveList.Quota           = header.Quota;
            saveList.Round           = header.Round;
            saveList.RouteQuantity   = header.RouteQuantity;
            saveList.StartTime       = header.StartTime;
            saveList.Style           = header.Style;
            return(saveList);
        }
예제 #4
0
        public JsonResult <ApiListHeader> PostListHeader(string id, string password, ApiListHeader listHeader)
        {
            if (!this.CheckCompetitionsPassword(id, password))
            {
                return(Json(listHeader));
            }
            var  list    = Context.ResultLists.FirstOrDefault(l => l.Iid == listHeader.Iid && l.CompId == id);
            bool newList = list == null;

            if (newList)
            {
                list = Context.ResultLists.Add(new ListHeader(Context)
                {
                    CompId = id
                });
            }

            if (string.IsNullOrEmpty(listHeader.AgeGroupInCompId))
            {
                list.AgeGroup = null;
                list.GroupId  = null;
            }
            else
            {
                list.AgeGroup = Context.AgeGroupsOnCompetition.FirstOrDefault(g => g.Iid == listHeader.AgeGroupInCompId);
                list.GroupId  = listHeader.AgeGroupInCompId;
            }

            if (string.IsNullOrEmpty(listHeader.IidParent))
            {
                list.Parent    = null;
                list.IidParent = null;
            }
            else
            {
                list.Parent    = Context.ResultLists.FirstOrDefault(l => l.Iid == listHeader.IidParent);
                list.IidParent = listHeader.IidParent;
            }

            list.ListType = listHeader.ListTypeV;
            list.Live     = listHeader.Live;

            if (string.IsNullOrEmpty(listHeader.PreviousRoundId))
            {
                list.PreviousRound = null;
                list.PrevRoundIid  = null;
            }
            else
            {
                list.PreviousRound = Context.ResultLists.FirstOrDefault(r => r.Iid == listHeader.PreviousRoundId);
                list.PrevRoundIid  = listHeader.PreviousRoundId;
            }

            list.Quota       = listHeader.Quota;
            list.Round       = listHeader.Round;
            list.RouteNumber = listHeader.RouteNumber;
            list.Rules       = listHeader.ClimbingRules;
            list.Style       = listHeader.Style;

            Context.SaveChanges();

            listHeader.Iid = list.Iid;
            return(Json(listHeader));
        }
 public AsyncRequestResult BeginPostListHeader(ApiListHeader region, RequestCompleted <object> callback, Object asyncState)
 {
     return(BeginPostSerializableTTOut("Results", "PostListHeader", String.Empty, region, callback, asyncState, false));
 }
 public bool PostListHeader(ApiListHeader listHeader)
 {
     PostSerializableT <ApiListHeader, object>("Results", "PostListHeader", String.Empty, listHeader, false);
     return(true);
 }