public bool AddEvent()
        {
            if (addEventWindow.EventName.Length == 0)
            {
                addEventWindow.Status = "Event name is empty";
                return(false);
            }
            if (addEventWindow.EventName.Length > 50)
            {
                addEventWindow.Status = "Event name have length lower than 50";
                return(false);
            }
            EventDao eventDao = new EventDao();

            eventDao.MakeConnection(Properties.Resources.strConnection);
            if (eventDao.Create(new EventDto(addEventWindow.EventName, addEventWindow.Desciption, "", ((App)Application.Current).UserName)))
            {
                List <CheckBox> groupShowList = (List <CheckBox>)addEventWindow.Group;
                int             index         = 0;
                foreach (CheckBox checkBox in groupShowList)
                {
                    if ((bool)checkBox.IsChecked)
                    {
                        EventAttendeesDao eventAttendeesDao = new EventAttendeesDao();
                        List <GroupDto>   groupDtos         = (List <GroupDto>)addEventWindow.GroupData;
                        eventAttendeesDao.MakeConnection(Properties.Resources.strConnection);
                        List <EventAttendeesDto> eventAttendeesDtos = eventAttendeesDao.ReadData(groupDtos[index].Id, "");
                        foreach (EventAttendeesDto eventAttendeesDto in eventAttendeesDtos)
                        {
                            CheckInDao checkInDao = new CheckInDao();
                            checkInDao.MakeConnection(Properties.Resources.strConnection);
                            CheckInDto checkInDto = new CheckInDto();
                            checkInDto.EventID = eventDao.GetLastId();
                            checkInDto.Name    = eventAttendeesDto.Name;
                            checkInDto.Email   = eventAttendeesDto.Email;
                            checkInDto.Other   = eventAttendeesDto.Other;
                            checkInDao.Create(checkInDto);
                        }
                    }
                    index++;
                }
            }
            return(true);
        }
Example #2
0
        public bool AddMemberInEvent()
        {
            if (detailMemberWindow.DataName.Length == 0)
            {
                detailMemberWindow.Status = "Member name is empty";
                return(false);
            }
            if (!IsValidEmail(detailMemberWindow.Email))
            {
                detailMemberWindow.Status = "Email invalidate";
                return(false);
            }
            CheckInDao checkInDao = new CheckInDao();

            checkInDao.MakeConnection(Properties.Resources.strConnection);
            CheckInDto checkInDto = new CheckInDto();

            checkInDto.Name    = detailMemberWindow.DataName;
            checkInDto.Email   = detailMemberWindow.Email;
            checkInDto.Other   = detailMemberWindow.Other;
            checkInDto.EventID = detailMemberWindow.Id;
            return(checkInDao.Create(checkInDto));
        }