Ejemplo n.º 1
0
 public static List <Participant> GetParticipantsByEvent(int eventId, string sortExperession, string sortDirection)
 {
     try
     {
         List <Participant> lstParticipants = new List <Participant>();
         using (var db = new PanaceaEventsModel())
         {
             lstParticipants = db.Participants.Where(p => p.EventId == eventId).ToList();
             if (lstParticipants != null && !string.IsNullOrEmpty(sortExperession) && !string.IsNullOrEmpty(sortDirection))
             {
                 if (sortDirection.ToLower() == "descending")
                 {
                     lstParticipants = lstParticipants.OrderByDescending(o => o.GetType().GetProperty(sortExperession).GetValue(o, null)).ToList();
                 }
                 else
                 {
                     lstParticipants = lstParticipants.OrderBy(o => o.GetType().GetProperty(sortExperession).GetValue(o, null)).ToList();
                 }
             }
         }
         return(lstParticipants);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 public static List <Event> GetEvents()
 {
     try
     {
         List <Event> lstEvents = new List <Event>();
         using (var db = new PanaceaEventsModel())
         {
             lstEvents = db.Events.OrderBy(e => e.Name).ToList();
         }
         return(lstEvents);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
        public static bool CheckIfParticipantExists(int eventId, string email)
        {
            try
            {
                bool exists = false;
                using (var db = new PanaceaEventsModel())
                {
                    var objParticipant = db.Participants.Where(p => p.EventId == eventId && p.Email.Trim().ToLower() == email.Trim().ToLower()).FirstOrDefault();

                    exists = (objParticipant != null);
                }
                return(exists);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
 public static bool AddParticipant(Participant objParticipant)
 {
     try
     {
         bool recordAdded = false;
         using (var db = new PanaceaEventsModel())
         {
             db.Participants.Add(objParticipant);
             db.SaveChanges();
             recordAdded = true;
         }
         return(recordAdded);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }