Exemple #1
0
        /*
         * Obsluga dodawania kolejnosci.
         */
        public static void changeOrder(long idCompetition, long idEvent, int points)
        {
            var db = new appDBEntities();

            if (idCompetition == 0)
            {
                MessageBox.Show(string.Format("Error: idCompetition =  {0},  idEvent = {1}", idCompetition, idEvent));
            }
            else
            {
                EventCompetitions c = (from EventCompetitions in db.EventCompetitions
                                       where EventCompetitions.CompetitionID == idCompetition && EventCompetitions.EventID == idEvent
                                       select EventCompetitions).First();
                if (c.Order == null)
                {
                    c.Order = 0;
                    c.Order = c.Order + points;
                }
                else
                {
                    c.Order = c.Order + points;
                }
                try
                {
                    db.SaveChanges();
                    //  MessageBox.Show(string.Format("Deleting participant with ID = {0}  from EventID = {1}", idParticipant, idEvent));
                }
                catch (Exception f)
                {
                    Console.WriteLine(f);
                    // Provide for exceptions.
                }
            }
        }
Exemple #2
0
 public static void addCompetitionToEvent(long idCompetition, long idEvent)
 {
     using (var db = new appDBEntities())
     {
         EventCompetitions newItem = new EventCompetitions
         {
             EventID       = idEvent,
             CompetitionID = idCompetition,
         };
         try
         {
             db.EventCompetitions.Add(newItem);
             db.SaveChanges();
             db.Dispose();
             //   MessageBox.Show(string.Format("Adding participant with ID = {0}  to EventID = {1}", idParticipant, idEvent));
         }
         catch (Exception f)
         {
             Console.WriteLine(f);
             // Provide for exceptions.
         }
     }
 }