Пример #1
0
        public ParticipantDTO FindParticipant(int id)
        {
            Participants participant = db.Participants
                                       .Include(i => i.EventID)
                                       .Include(i => i.AccountID)
                                       .SingleOrDefault(x => x.Id == id);

            ParticipantDTO participantDto = MapParticipantToDTO(participant);

            return(participantDto);
        }
Пример #2
0
        public ParticipantDTO MapParticipantToDTO(Participants participant)
        {
            ParticipantDTO participantDto = new ParticipantDTO();

            participantDto.Id                  = participant.Id;
            participantDto.eventId             = participant.EventID.Id;
            participantDto.NumberOfTicket      = participant.NumberOfTicket;
            participantDto.Reminder            = participant.Reminder;
            participantDto.userId              = participant.AccountID.Id;
            participantDto.emailNotificationOn = participant.emailNotificationOn;
            participantDto.SMSNotificationOn   = participant.SMSNotificationOn;
            participantDto.Barcodes            = GetBarcodeGuidsByParticipant(participant.Id);

            return(participantDto);
        }
Пример #3
0
        public ParticipantDTO FindParticipantByBarcode(string guid)
        {
            Barcodes barcode = db.Barcodes
                               .Where(x => x.Barcode.ToString() == guid && x.IsActive == true)
                               .SingleOrDefault();

            ParticipantDTO pDTO = new ParticipantDTO();

            Participants participant = db.Participants
                                       .Include(x => x.Barcodes)
                                       .Include(x => x.EventID)
                                       .Include(x => x.AccountID)
                                       .Where(x => x.Barcodes.Select(y => y.Id).ToList().Contains(barcode.Id) && x.IsActive == true)
                                       .SingleOrDefault();

            pDTO = MapParticipantToDTO(participant);
            return(pDTO);
        }
Пример #4
0
        public void UpdateParticipantReminders(ParticipantDTO pDTO)
        {
            string          userId = HttpContext.Current.User.Identity.GetUserId();
            ApplicationUser user   = db.Users.Find(userId);

            Participants pRec = db.Participants.Find(pDTO.Id);

            pRec.Reminder            = pDTO.Reminder;
            pRec.emailNotificationOn = pDTO.emailNotificationOn;
            pRec.SMSNotificationOn   = pDTO.SMSNotificationOn;

            if (pDTO.Phone != ConstantValues.phoneValidation && pDTO.Phone != null)
            {
                user.PhoneNumber = pDTO.Phone;
            }

            db.Entry(pRec).State = EntityState.Modified;
            db.SaveChanges();
        }
Пример #5
0
        public List <ParticipantDTO> QueryUserEventsAttending()
        {
            string                userId  = HttpContext.Current.User.Identity.GetUserId();
            ApplicationUser       user    = db.Users.Find(userId);
            List <ParticipantDTO> dtoList = new List <ParticipantDTO>();

            List <Participants> participantsList = db.Participants
                                                   .Include(i => i.EventID)
                                                   .Include(i => i.AccountID)
                                                   .Where(i => i.AccountID.Id == userId && i.EventID.IsActive == true && i.EventID.TimeStart >= DateTime.Now)
                                                   //.OrderBy(i => i.EventID.TimeStart)
                                                   .ToList();

            foreach (Participants userEvents in participantsList)
            {
                ParticipantDTO participantDto = MapParticipantToDTO(userEvents);
                dtoList.Add(participantDto);
            }

            return(dtoList);
        }
Пример #6
0
        public int CreateParticipant(ParticipantDTO participantsDTO)
        {
            string          userId = HttpContext.Current.User.Identity.GetUserId();
            ApplicationUser user   = db.Users.Find(userId);
            Events          events = db.Events.Find(participantsDTO.eventId);

            List <Barcodes> barcodes = new List <Barcodes>();

            foreach (Guid barcode in participantsDTO.Barcodes)
            {
                var barcodeRecord = new Barcodes
                {
                    Barcode     = barcode,
                    CreatedBy   = user,
                    CreatedDate = DateTime.Now,
                    IsActive    = true
                };

                barcodes.Add(barcodeRecord);
            }


            var participant = new Participants
            {
                AccountID      = user,
                NumberOfTicket = participantsDTO.NumberOfTicket,
                Reminder       = participantsDTO.Reminder,
                EventID        = events,
                CreatedBy      = user,
                IsActive       = true,
                CreatedDate    = DateTime.Now,
                Barcodes       = barcodes
            };

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

            return(participant.Id);
        }