Ejemplo n.º 1
0
        public async Task <ObjectResult> Update(Guid id, [FromBody] ParticipantData participantData, User user)
        {
            if (user.Role == UserRole.Participant && user.Id != participantData.User.Id)
            {
                return(StatusCode(400, "Нет прав"));
            }
            if (string.IsNullOrEmpty(participantData.User.School))
            {
                return(StatusCode(400, "Не заполнена школа"));
            }
            if (!participantData.User.Class.HasValue)
            {
                return(StatusCode(400, "Не указан класс"));
            }

            var contest = await contestsRepo.GetByIdAsync(id);

            if (contest.Type == ContestType.Common && string.IsNullOrWhiteSpace(participantData.Verification))
            {
                return(StatusCode(400, "Не заполнено подтверждение"));
            }

            await contestManager.AddOrUpdateParticipant(id, participantData.User, participantData.Verification);

            return(StatusCode(200, "Успешно"));
        }
Ejemplo n.º 2
0
 public CheckParticipantParam()
 {
     this.IsSuccessed = false;
     this.HasError    = false;
     this.NoExistUser = false;
     this.Participant = new ParticipantData();
 }
Ejemplo n.º 3
0
        public ActionResult SaveParticipant(ParticipantModel model)
        {
            ParticipantData MemRepo = new ParticipantData();

            model.CLPid        = 1;
            model.DateEntered  = DateTime.Now;
            model.ModifiedDate = DateTime.Now;
            model.EnteredBy    = 1;     //user
            model.ModifiedBy   = 1;     //user

            if (ModelState.IsValid)
            {
                ResponseModel isSave = MemRepo.SaveParticipant(model);
                if (isSave.status == 1)
                {
                    Connection.CommitTransaction();
                    Connection.CloseConnection();
                    return(Json(new { status = true, code = 2, msg = "Successfuly Created." }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    Connection.RollbackTransaction();
                    Connection.CloseConnection();
                    return(Json(new { status = false, code = 0, msg = "Something went wrong." }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { status = false, code = 0, msg = "Something went wrong." }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 4
0
        public static Domain.Participant.Participant Create(ParticipantView view)
        {
            var d = new ParticipantData();

            Copy.Members(view, d);

            return(new Domain.Participant.Participant(d));
        }
Ejemplo n.º 5
0
        public static async Task SendMessage(ParticipantData participant, string message)
        {
            if (participant.IsDiscordIdValid())
            {
                var user = await restClient.GetUserAsync(participant.discordId);

                await user.SendMessageAsync(message);
            }
        }
Ejemplo n.º 6
0
        // GET: Participant
        public ActionResult Index()
        {
            #region List
            ParticipantModel model = new ParticipantModel();
            model.MemberList = ParticipantData.GetMemberParticipantList();
            model.GroupList  = ParticipantData.GetGroupList();
            model.StatusList = ParticipantData.GetStatusList();

            return(View(model));
        }
Ejemplo n.º 7
0
            public static ParticipantData Create(byte[] bytes)
            {
                ParticipantData  ReturnInstance = new ParticipantData();
                ByteArrayManager BAM            = new ByteArrayManager(bytes);

                //Get AI controlled
                byte nb = BAM.NextByte();

                if (nb == 0)
                {
                    ReturnInstance.IsAiControlled = false;
                }
                else if (nb == 1)
                {
                    ReturnInstance.IsAiControlled = true;
                }


                //Get piloting driver
                ReturnInstance.PilotingDriver = CodemastersToolkit.GetDriverFromDriverId(BAM.NextByte(), Game.F1_2019);

                //Get Team
                ReturnInstance.ManufacturingTeam = CodemastersToolkit.GetTeamFromTeamId(BAM.NextByte(), Game.F1_2019);

                //Get race number
                ReturnInstance.CarRaceNumber = BAM.NextByte();

                //Get nationallity ID
                ReturnInstance.NationalityId = BAM.NextByte();

                //Get name
                string FullName = "";
                int    t        = 1;

                for (t = 1; t <= 48; t++)
                {
                    char ThisChar = Convert.ToChar(BAM.NextByte());
                    FullName = FullName + ThisChar.ToString();
                }
                ReturnInstance.Name = FullName.Trim();

                //Get telemetry private or not.
                nb = BAM.NextByte();
                if (nb == 0)
                {
                    ReturnInstance.TelemetryPrivate = false;
                }
                else if (nb == 1)
                {
                    ReturnInstance.TelemetryPrivate = true;
                }


                return(ReturnInstance);
            }
Ejemplo n.º 8
0
        public PacketParticipantsData(PacketHeader packetHeader)
        {
            Header = packetHeader;

            Participants = new ParticipantData[Decode.MaxNumberOfCarsOnTrack];

            for (int i = 0; i < Decode.MaxNumberOfCarsOnTrack; i++)
            {
                Participants[i] = new ParticipantData();
            }
        }
Ejemplo n.º 9
0
        public Participant AjoutParticipant(Participant participant)
        {
            var participantData = new ParticipantData();

            if (new DossierData().GetById(participant.DossierReservationId) != null &&
                participantData.GetList()
                .Where(x => x.DossierReservationId == participant.DossierReservationId).Count() < 9)
            {
                participantData.Ajouter(participant);
            }
            return(participant);
        }
Ejemplo n.º 10
0
        public ActionResult ModifyParticipant(int id)
        {
            ParticipantData  partRepo = new ParticipantData();
            ParticipantModel model    = partRepo.GetParticipant(id);

            if (model.id > 0)
            {
                return(Json(new { status = true, result = model, msg = "Successfuly Created." }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { status = false, code = 0, msg = "Something went wrong." }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 11
0
        public ActionResult ParticipantList()
        {
            List <ParticipantModel> model = ParticipantData.ParticipantList(0);

            if (model.Count() == 0)
            {
                return(Json(new { status = false, msg = "No data found!" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                //get supplier name
            }

            return(Json(new { status = true, msg = "Success", data = RenderPartialViewToString("_ParticipantListPartial", model) }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Saves the participant event.
        /// </summary>
        /// <param name="data">The data.</param>
        private async Task _saveParticipantEvent(CollectionEventArgs <IParticipant> data)
        {
            var added = new List <IParticipant>();

            data.AddedResources.ForEach(x => added.Add(new ParticipantExtension(x)));

            var removed = new List <IParticipant>();

            data.RemovedResources.ForEach(x => removed.Add(new ParticipantExtension(x)));

            var participant = new ParticipantData {
                AddedResources = added, RemovedResources = removed
            };

            await saveJsonFile(participant, $"{DateTime.UtcNow.Ticks.ToString()}-participant.json");
        }
Ejemplo n.º 13
0
        public override void LoadBytes(byte[] bytes)
        {
            ByteArrayManager BAM = new ByteArrayManager(bytes);

            base.LoadBytes(BAM.NextBytes(23));

            NumberOfActiveCars = BAM.NextByte();

            List <ParticipantData> PDs = new List <ParticipantData>();
            int t = 1;

            for (t = 1; t <= 20; t++)
            {
                PDs.Add(ParticipantData.Create(BAM.NextBytes(54)));
            }
            FieldParticipantData = PDs.ToArray();
        }
Ejemplo n.º 14
0
            /// <summary>
            /// Retrieve a single participant record for a tournament
            /// </summary>
            /// <param name="tournament">Tournament ID (e.g. 10230) or URL (e.g. 'single_elim' for
            /// challonge.com/single_elim). If assigned to a subdomain, URL format must be
            /// subdomain-tournament_url (e.g. 'test-mytourney' for test.challonge.com/mytourney) </param>
            /// <param name="participantId">The participant's unique ID </param>
            /// <param name="includeMatches"></param>
            /// <returns>A result containing the participant and if requested its match records</returns>
            public async Task <ParticipantApiResult> GetParticipantAsync(string tournament, int participantId, bool includeMatches = false)
            {
                string request = $"https://api.challonge.com/v1/tournaments/{tournament}/participants/{participantId}.json?api_key={_apiKey}";

                if (includeMatches)
                {
                    request += "&include_matches=1";
                }

                HttpResponseMessage response = await _httpClient.GetAsync(request);

                string responseString = await ErrorHandler.ParseResponseAsync(response);

                ParticipantApiResult result = new ParticipantApiResult();

                if (includeMatches)
                {
                    JsonElement matchesElement = JsonDocument.Parse(responseString).RootElement.GetProperty("participant").GetProperty("matches");

                    MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(matchesElement.GetRawText()));

                    MatchData[] matches = await JsonSerializer.DeserializeAsync <MatchData[]>(stream);

                    Match[] matchesResult = new Match[matches.Length];

                    for (int i = 0; i < matches.Length; i++)
                    {
                        matchesResult[i] = matches[i].Match;
                    }

                    result.Matches = matchesResult;
                }
                else
                {
                    result.Matches = null;
                }

                MemoryStream    reader          = new MemoryStream(Encoding.UTF8.GetBytes(responseString));
                ParticipantData participantData = await JsonSerializer.DeserializeAsync <ParticipantData>(reader);

                result.Participant = participantData.Participant;

                return(result);
            }
Ejemplo n.º 15
0
            /// <summary>
            /// Add a participant to a tournament (up until it is started)
            /// </summary>
            /// <param name="tournament">Tournament ID (e.g. 10230) or URL (e.g. 'single_elim' for
            /// challonge.com/single_elim). If assigned to a subdomain, URL format must be
            /// subdomain-tournament_url (e.g. 'test-mytourney' for test.challonge.com/mytourney) </param>
            /// <param name="name">The name displayed in the bracket/schedule - not required if email
            /// or challongeUsername is provided. Must be unique per tournament. </param>
            /// <param name="challongeUsername">Provide this if the participant has a Challonge account.
            /// He or she will be invited to the tournament. </param>
            /// <param name="email">Providing this will first search for a matching Challonge account. If one
            /// is found, this will have the same effect as the "challonge_username" attribute. If one is not
            /// found, the "new-user-email" attribute will be set, and the user will be invited via email to
            /// create an account. </param>
            /// <param name="seed">The participant's new seed. Must be between 1 and the current number of
            /// participants (including the new record). Overwriting an existing seed will automatically bump
            /// other participants as you would expect. </param>
            /// <param name="misc"> Max: 255 characters. Multi-purpose field that is only visible via the API
            /// and handy for site integration (e.g. key to your users table) </param>
            /// <returns>The created participant</returns>
            public async Task <Participant> CreateParticipantAsync(string tournament, string name = null,
                                                                   string challongeUsername       = null, string email = null, int?seed = null, string misc = null)
            {
                string request = $"https://api.challonge.com/v1/tournaments/{tournament}/participants.json";

                Dictionary <string, string> parameters = new Dictionary <string, string>
                {
                    ["api_key"] = _apiKey
                };

                if (name != null)
                {
                    parameters["participant[name]"] = name;
                }

                if (challongeUsername != null)
                {
                    parameters["participant[challonge_username]"] = challongeUsername;
                }

                if (email != null)
                {
                    parameters["participant[email]"] = email;
                }

                if (seed != null)
                {
                    parameters["participant[seed]"] = seed.ToString();
                }

                if (misc != null)
                {
                    parameters["participant[misc]"] = misc;
                }

                FormUrlEncodedContent content = new FormUrlEncodedContent(parameters);

                ParticipantData participantData = await PostAsync <ParticipantData>(_httpClient, request, content);

                return(participantData.Participant);
            }
Ejemplo n.º 16
0
        public bool AddParticipant(ParticipantData Participant)
        {
            bool isTransactionCommitted;

            try
            {
                var participant = Mapper.Map <ParticipantData, Participant>(Participant);

                participant.PositionId = _promoDb.Positions.Where(p => p.PositionName == Participant.Position).Select(i => i.Id).First();

                _promoDb.Participants.Add(participant);
                _promoDb.SaveChanges();

                isTransactionCommitted = true;
            }
            catch (Exception ex)
            {
                isTransactionCommitted = false;
            }

            return(isTransactionCommitted);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 会議入室の際の参加者情報を登録するAPIコール
        /// </summary>
        /// <param name="uri">コールするURL</param>
        /// <param name="uid">参加者のユーザーID</param>
        /// <param name="mid">入室対象の会議ID</param>
        /// <returns>CreateParticipateParam</returns>
        public async Task <CreateParticipateParam> CreateParticipateDataAsync(string uri, int uid, int mid)
        {
            var participantData = new ParticipantData(uid, mid);
            var json            = JsonConvert.SerializeObject(participantData);

            var jobj = JObject.Parse(json);

            //MeetingDataモデルからJSON化に不要な属性を削除
            jobj.Remove("id");
            jobj.Remove("UserId");
            jobj.Remove("LabelItems");

            json = JsonConvert.SerializeObject(jobj);

            var createParticipateParam = new CreateParticipateParam();

            try
            {
                var content = new StringContent(json, Encoding.UTF8, "application/json");


                var response = await _client.PostAsync(uri, content);

                string responseContent = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    //string responseContent = await response.Content.ReadAsStringAsync();
                    Console.WriteLine(responseContent);
                    createParticipateParam.IsSuccessed = response.IsSuccessStatusCode;
                    return(createParticipateParam);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\tERROR {0}", ex.Message);
            }
            return(createParticipateParam);
        }
Ejemplo n.º 18
0
        private void CboSheet_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataTable dt = tableCollection[CboSheet.SelectedItem.ToString()];

            //dataGrid.ItemsSource = dt.DefaultView;
            if (dt != null)
            {
                List <ParticipantData> participant = new List <ParticipantData>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ParticipantData participants = new ParticipantData();
                    participants.ParticipantID       = Int32.Parse(dt.Rows[i]["ParticipantID"].ToString());
                    participants.AccreditationNumber = dt.Rows[i]["AccreditationNumber"].ToString();
                    participants.FullName            = dt.Rows[i]["FullName"].ToString();
                    participants.FamilyName          = dt.Rows[i]["FamilyName"].ToString();
                    participants.GenderID            = dt.Rows[i]["GenderID"].ToString();;
                    participants.CountryID           = dt.Rows[i]["CountryID"].ToString();
                    participants.PassportNumber      = dt.Rows[i]["PassportNumber"].ToString();
                    participants.DateOfBirth         = Convert.ToDateTime(dt.Rows[i]["DateOfBirth"].ToString());
                    participants.Weight                 = dt.Rows[i]["Weight"].ToString();
                    participants.Height                 = dt.Rows[i]["Height"].ToString();
                    participants.IsActive               = "1";
                    participants.CreatedBy              = "0";
                    participants.CreatedDateTime        = DateTime.Now;
                    participants.ModifiedBy             = "0";
                    participants.ModifiedDateTime       = DateTime.Now;
                    participants.GivenName              = dt.Rows[i]["GivenName"].ToString();
                    participants.IPCNo                  = dt.Rows[i]["IPCNo"].ToString();
                    participants.CardPhotoPath          = dt.Rows[i]["CardPhotoPath"].ToString();
                    participants.CardPhotoPathThumbnail = dt.Rows[i]["CardPhotoPathThumbnail"].ToString();
                    participants.CardPhotoPathExternal  = dt.Rows[i]["CardPhotoPathExternal"].ToString();
                    participants.ExternalParticipantID  = 0;
                    participant.Add(participants);
                }
                dgrid1.ItemsSource = participant;
            }
        }
Ejemplo n.º 19
0
        private static IPacket Participants(PacketHeader packetHeader, BinaryReader reader)
        {
            var packetParticipantsData = new PacketParticipantsData(packetHeader);

            packetParticipantsData.NumActiveCars = reader.ReadByte();

            for (int i = 0; i < MaxNumberOfCarsOnTrack; i++)
            {
                var participantData = new ParticipantData();

                packetParticipantsData.Participants[i] = participantData;

                participantData.AiControlled = (reader.ReadByte() != 0);
                participantData.DriverId     = reader.ReadByte();
                participantData.TeamId       = reader.ReadByte();
                participantData.RaceNumber   = reader.ReadByte();
                participantData.Nationality  = reader.ReadByte();
                participantData.Name         = reader.ReadChars(47);

                participantData.YourTelemetry = (TelemetrySetting)reader.ReadByte();
            }

            return(packetParticipantsData);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 会議の参加者情報を更新するAPIコール
        /// </summary>
        /// <param name="uri">コールするURL</param>
        /// <param name="participant">参加者の更新内容情報</param>
        /// <returns>UpdateParticipantParam</returns>
        public async Task <UpdateParticipantParam> UpdateParticipantDataAsync(string uri, ParticipantData participant)
        {
            var json = JsonConvert.SerializeObject(participant);
            var updateParticipantParam = new UpdateParticipantParam();

            var content = new StringContent(json, Encoding.UTF8, "application/json");

            try
            {
                HttpResponseMessage response = await _client.PutAsync(uri, content);


                if (!response.IsSuccessStatusCode)
                {
                    updateParticipantParam.HasError = true;
                    return(updateParticipantParam);
                }


                //成功した場合
                if (response.IsSuccessStatusCode)
                {
                    string responseContent = await response.Content.ReadAsStringAsync();

                    //Paramを成功に
                    updateParticipantParam.IsSuccessed = response.IsSuccessStatusCode;
                    return(updateParticipantParam);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\tERROR {0}", ex.Message);
                updateParticipantParam.HasError = true;
            }
            return(updateParticipantParam);
        }