Ejemplo n.º 1
0
        public void addParticipant(User participant, bool important)
        {
            participant tempParticipant = new participant(participant, important);

            participants.Add(tempParticipant);
            noOfParticipants++;
        }
Ejemplo n.º 2
0
        public ActionResult addProject(project pj, int[] array)
        {
            int         projId = 0;
            participant pp     = new participant();

            try {
                pj.userId      = array[0];
                pj.lastupdated = DateTime.Now.ToString("dddd, dd MMMM yyyy hh:mm tt");
                pj.createddate = DateTime.Now.ToString("dddd, dd MMMM yyyy hh:mm tt");
                pj.status      = "Active";
                db.projects.Add(pj);
                db.SaveChanges();

                projId = pj.projId;
                for (int i = 0; i < array.Length; i++)
                {
                    pp.projId = projId;
                    pp.userId = array[i];
                    pp.status = "Active";
                    db.participants.Add(pp);
                    db.SaveChanges();
                }
                var data = new { status = "Success", projId = pj.projId };
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(projId, JsonRequestBehavior.AllowGet));
            }
        }
        private void doCrud(participant p)
        {
            switch (currentCrudOp)
            {
            // create
            case CrudOpr.Create:
                if (crud.create(p) != null)
                {
                    MessageBox.Show("Participant was added!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Adding was denied");
                }
                break;

            case CrudOpr.Update:

                if (crud.update(p))
                {
                    MessageBox.Show("Participant was updated!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Updating was denied");
                }
                break;
            }
        }
        private void OkButton_Click(object sender, EventArgs e)
        {
            checkData();

            participant p = new participant();

            p.conference  = participantDTO.conference;
            p.subject     = participantDTO.subject;
            p.theme       = participantDTO.theme;
            p.publication = isChecked ? "y" : "n";


            switch (currentCrudOp)
            {
            case CrudOpr.Update:
                p.scientist     = formDTO.obj.scientistId;
                p.participantId = formDTO.obj.participantId;
                break;

            case CrudOpr.Create:
                p.scientist = scientist.scientistId;
                break;
            }

            doCrud(p);
        }
Ejemplo n.º 5
0
        public ActionResult SaveparticipantInfo(participant participant)
        {
            FillDropListForParticipent();

            if (ModelState.IsValid)
            {
                var CheckEmailExist = (from i in DBentities.participant
                                       where i.Email.ToLower() == participant.Email.ToLower()
                                       select i).FirstOrDefault();
                if (CheckEmailExist != null)
                {
                    Session["userID"] = CheckEmailExist.ID;
                    return(RedirectToAction("classification", "Home", new { @skip = 1 }));
                }
                else
                {
                    participant newparticipant = new participant();
                    newparticipant.Email      = participant.Email;
                    newparticipant.JobTitle   = participant.JobTitle;
                    newparticipant.Experience = participant.Experience;
                    DBentities.participant.Add(newparticipant);
                    DBentities.SaveChanges();
                    Session["userID"] = newparticipant.ID;

                    return(RedirectToAction("classification", "Home", new { @skip = 1 }));
                }
            }
            return(View("participantInfo", participant));
        }
Ejemplo n.º 6
0
        public ActionResult updateProject(project project, int[] users, int[] Rusers)
        {
            //try {


            db.Entry(project).State = EntityState.Modified;
            db.SaveChanges();



            if (users != null)
            {
                for (int i = 0; i < users.Length; i++)
                {
                    int userId = users[i];
                    var pps    = db.participants.Where(e => e.projId == project.projId && e.userId == userId).ToList();
                    if (pps.Count() == 1)
                    {
                        participant pp = pps[0];
                        pp.status          = "Active";
                        db.Entry(pp).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                        participant pp = new participant();
                        pp.projId = project.projId;
                        pp.userId = users[i];
                        pp.status = "Active";
                        db.participants.Add(pp);
                        db.SaveChanges();
                    }
                }
            }


            if (Rusers != null)
            {
                for (int i = 0; i < Rusers.Length; i++)
                {
                    var userId      = Rusers[i];
                    var participant = db.participants.Where(e => e.projId == project.projId && e.userId == userId).First();
                    participant.status          = "Removed";
                    db.Entry(participant).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }


            return(Json("Success", JsonRequestBehavior.AllowGet));
            //}
            //catch (Exception e)
            //{
            //    return Json("Success", JsonRequestBehavior.AllowGet);
            //}
        }
Ejemplo n.º 7
0
            public void addParticipant( string uuid )
            {
                var index = this.participants.FindIndex( participant => participant.uuid == uuid );
                if ( index != -1 )
                    return;

                var new_participant = new participant( uuid );

              
                this.participants.Add( new_participant );
            }
        static public bool IsParticipantExist(participant candidate, List <participant> participants)
        {
            List <participant> existingOne = participants.Where(o => o.name == candidate.name).ToList();

            if (existingOne.Count != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 static public bool IsValide(participant participant)
 {
     try
     {
         if (PropretyValidation.IsStringValide(participant.name, participant.nameMin, participant.nameMax))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells["participantIdDataGridViewTextBoxColumn"].Value);

            // updating
            if (e.ColumnIndex == 9)
            {
                formDTO.op = CrudOpr.Update;

                ViewConferencesWithParticipant findParticipant = dataFormDTO.db.ViewConferencesWithParticipants.SingleOrDefault(o => o.participantId == id);
                formDTO.obj = findParticipant;

                CreateUpdateParticipantForm form = new CreateUpdateParticipantForm(this, formDTO);
                form.Show();
            }

            // deleting
            if (e.ColumnIndex == 10)
            {
                // Запрашиваем подтверждение
                string message = "Do you want to delete?";
                string caption = "Y/n";
                var    result  = MessageBox.Show(message, caption,
                                                 MessageBoxButtons.YesNo,
                                                 MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    participant participant = new participant();
                    participant.participantId = id;
                    // deleting
                    if (crud.delete(participant))
                    {
                        MessageBox.Show("Conference was deleted!");
                        resetData();
                    }
                    else
                    {
                        MessageBox.Show("Deleting was denied");
                    }
                }
            }
        }
Ejemplo n.º 11
0
 public bool DeleteParticipant(int id)
 {
     try
     {
         if (db.participants.Find(id) != null)
         {
             participant participant = db.participants.Find(id);
             db.participants.Remove(participant);
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        /// <summary>
        /// Save your Tournament!
        /// </summary>
        /// <param name="tournamentViewModel"></param>
        public void SaveTournament(CreateTournamentViewModel tournamentViewModel)
        {
            tournament newTournament = new tournament
            {
                tournament_name    = tournamentViewModel.TournamentName,
                tournament_type_id = tournamentViewModel.TournamentType,
                //TODO: user id
                tournament_host_id  = 1,
                number_participants = tournamentViewModel.Participants.Count
            };

            UnitOfWork.TournamentRepository.InsertAndSave(newTournament);

            var allParticipants = UnitOfWork.ParticipantRepository.All();
            var participantList = new List <participant>();

            //save the new participants
            foreach (var participantName in tournamentViewModel.Participants)
            {
                var participantExist = allParticipants.Where(x => x.participant_name == participantName).FirstOrDefault();
                if (participantExist == null)
                {
                    var newParticipant = new participant
                    {
                        participant_name = participantName
                    };
                    UnitOfWork.ParticipantRepository.InsertAndSave(newParticipant);
                    participantExist = newParticipant;
                }
                participantList.Add(participantExist);
                var tournament_participant = new tournament_participant_rel
                {
                    tournament_id  = newTournament.tournament_id,
                    participant_id = participantExist.participant_id
                };
                UnitOfWork.Tournament_participant_RelRepository.InsertAndSave(tournament_participant);
            }
            GenerateCompetition(participantList, newTournament);
        }
Ejemplo n.º 13
0
 public bool PutParticipant(participant participant)
 {
     try
     {
         if (ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant()) && ValidatorParticipant.IsValide(participant))
         {
             db.Entry(participant).State = EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         else if (!ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant()))
         {
             throw new ItemNotExistException("participant");
         }
         else
         {
             throw new InvalidItemException("participant");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 14
0
 public bool PostParticipant(participant participant)
 {
     try
     {
         if (ValidatorParticipant.IsValide(participant) && !ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant()))
         {
             db.participants.Add(participant);
             db.SaveChanges();
             return(true);
         }
         else if (ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant()))
         {
             throw new ExistingItemException("participant");
         }
         else
         {
             throw new InvalidItemException("participant");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 15
0
 public void addParticipantByIdEvent(participant participantr)
 {
     // ut.ParticipantRepository.Add().;
 }