示例#1
0
        private Data.Event CreateEvent(Meeting meeting)
        {
            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    var users = db.EventUsers.Where(i => i.Meeting.Id == meeting.Id).ToList().Select(i => i.ToXferData());
                    var items = db.EventQueueItems.Where(i => i.Meeting.Id == meeting.Id).ToList().Select(i => i.ToXferData());

                    var ev = new Data.Event
                    {
                        MeetingId  = meeting.Id,
                        Status     = meeting.Status,
                        Users      = users,
                        QueueItems = items,
                    };

                    return(ev);
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }
            return(null);
        }
示例#2
0
 public Event(Data.Event evnt)
 {
     EventId   = evnt.EventId.ToByteArray();
     EventType = evnt.EventType;
     Data      = evnt.Data;
     Metadata  = evnt.Metadata;
 }
示例#3
0
        public EventViewModels UpdateEvent(Container_Classes.Event UpdatedEvent)
        {
            // Retreieve the existing event from the data to update it.
            Data.Event dataEvent = _repository.Get <Data.Event>(x => x.EventID == UpdatedEvent.ID);
            if (dataEvent == null)
            {
                // The event does not exist in the database.
                return(EventNotFound());
            }

            // Convert the type string and category string to database keys
            Data.Type dataType = _repository.Get <Data.Type>(x => x.Type1.Equals(UpdatedEvent.Type));
            if (dataType == null)
            {
                // Could not map type to the database
                return(null);
            }


            // The event exists and we have it stored as data event. Let's update it.
            dataEvent = Container_Classes.Event.ContainerEventToDataEvent(UpdatedEvent, 1, dataType.TypeID, UpdatedEvent.Owner_ID);
            _repository.Update <Data.Event>(dataEvent);

            _repository.SaveChanges();

            EventViewModels model = new EventViewModels();

            model.Event = UpdatedEvent;

            return(model);
        }
示例#4
0
        public EventViewModels CreateEvent(Container_Classes.Event NewEvent)
        {
            int typeID = int.Parse(NewEvent.Type);

            // Convert the type string and category string to database keys
            Data.Type dataType = _repository.Get <Data.Type>(x => x.TypeID == typeID);
            if (dataType == null)
            {
                // Could not map type to the database
                return(null);
            }

            Data.Category dataCategory = _repository.Get <Data.Category>(x => x.Category1.Equals(NewEvent.Category));

            // Convert the Container Event into a Data Event so it can be added to the database
            Data.Event dataEvent = Container_Classes.Event.ContainerEventToDataEvent(NewEvent, dataCategory.CategoryID, dataType.TypeID, NewEvent.Owner_ID);
            _repository.Add <Data.Event>(dataEvent);
            _repository.SaveChanges();

            // Weak way of getting new event, this should break if two events have the same name!
            dataEvent = _repository.Get <Data.Event>(x => x.Title == NewEvent.Title);

            // Assign the ID to the added container object event
            NewEvent.ID = dataEvent.EventID;

            EventViewModels model = new EventViewModels();

            model.Event = NewEvent;

            return(model);
        }
示例#5
0
        public ICollection <Event> GetEvents(ICollection <Visited> AllVisits)
        {
            List <Event> events = new List <Event>();

            foreach (var visit in AllVisits)
            {
                if (visit.AddToCalendar == true)
                {
                    var visitdetails = new Data.Event
                    {
                        id                = visit.Event.id,
                        title             = $"{visit.Event.TypeOfEvent} at {visit.Event.Business.Name}, {visit.Event.City}",
                        TypeOfEvent       = visit.Event.TypeOfEvent,
                        BusinessID        = visit.Event.BusinessID,
                        Business          = visit.Event.Business,
                        start             = visit.Event.start,
                        end               = visit.Event.end,
                        ThirdPartyWebsite = visit.Event.ThirdPartyWebsite,
                        color             = visit.Event.color,
                    };
                    events.Add(visitdetails);
                }
            }
            return(events);
        }
示例#6
0
        public static Event Map(this Data.Event e)
        {
            Event result = new Event()
            {
                ID                          = e.ID,
                Name                        = e.Name,
                Description                 = e.Description,
                TwitterHashTag              = e.TwitterHashTag,
                StartTime                   = e.StartTime,
                EndTime                     = e.EndTime,
                Location                    = e.Location,
                Address1                    = e.Address1,
                Address2                    = e.Address2,
                City                        = e.City,
                State                       = e.State,
                Zip                         = e.Zip,
                IsDefault                   = e.IsDefault,
                IsSponsorRegistrationOpen   = e.IsSponsorRegistrationOpen,
                IsSpeakerRegistrationOpen   = e.IsSpeakerRegistrationOpen,
                IsAttendeeRegistrationOpen  = e.IsAttendeeRegistrationOpen,
                IsVolunteerRegistrationOpen = e.IsVolunteerRegistrationOpen
            };

            return(result);
        }
示例#7
0
 public static EventModel Create(Data.Event e, string userId)
 => new EventModel
 {
     Id          = e.Id,
     Title       = e.Title,
     Description = e.Description,
     OpensAt     = e.SignupOptions.SignupOpensAt,
     UserSignup  = e.Signups.FirstOrDefault(s => s.UserId == userId)
 };
示例#8
0
 public Event ToWebModel(Data.Event domainEvent)
 {
     return(new Event
     {
         DoorGuid = domainEvent.DoorGuid,
         UserGuid = domainEvent.UserGuid,
         CreatedOn = domainEvent.CreatedOn,
         EventType = domainEvent.EventType
     });
 }
示例#9
0
 public PresenceModel(Data.Event e)
 {
     Id          = e.Id;
     Title       = e.Title;
     Description = e.Description;
     Count       = e.LessonCount;
     Roles       = e.Signups
                   .GroupBy(x => x.Role, x => x, (role, signups) => new PresenceRoleModel(role, signups, e.LessonCount))
                   .ToReadOnlyCollection();
 }
示例#10
0
 public static SignupModel Create(Data.Event e)
 => new SignupModel
 {
     Id          = e.Id,
     Title       = e.Title,
     Description = e.Description,
     Options     = e.SignupOptions,
     IsOpen      = e.IsOpen(),
     HasClosed   = e.HasClosed(),
     Questions   = e.Questions.Select(q => SignupQuestion.Create(q)).ToList()
 };
示例#11
0
 public static QuestionsModel Create(Data.Event e, string filter) =>
 new QuestionsModel
 {
     EventId          = e.Id,
     EventTitle       = e.Title,
     EventDescription = e.Description,
     Filter           = filter,
     Signups          = e.Signups.ToList(),
     Questions        = e.Questions
                        .Select(q => QuestionModel.Create(q))
                        .ToList()
 };
示例#12
0
        public Detail(Data.Event e)
        {
            InitializeComponent();
            var htmlSource = new HtmlWebViewSource();

            htmlSource.Html = e.BodyText.Replace("<p>", "<p style=\"font-size:90%;\">");
            bodyView.Source = htmlSource;
            var htmlSource1 = new HtmlWebViewSource();

            htmlSource1.Html   = e.Description.Replace("<p>", "<p style=\"font-size:90%;\">");
            descripView.Source = htmlSource1;
            shower.Source      = (e.Picture);
            Title           = e.Title;
            titleLabel.Text = e.Title;
            CurrentEvent    = e;

            if (e.DateEnd.Equals("31.12.9998 21:00"))
            {
                end.Text = "";
            }
            else
            {
                end.Text = "Конец: " + e.DateEnd;
            }
            this.address.Text = e.Address;
            if (Address == null && DateTime.Parse(e.DateStart) > DateTime.Parse("01.03.2020"))
            {
                address.Text = "Из-за коронавируса событие проводится онлайн.";
            }

            else if (Address == null && DateTime.Parse(e.DateStart) < DateTime.Parse("01.03.2020"))
            {
                address.Text = "";
            }
            else if (e.DateStart.Equals("02.01.0001 21:30"))
            {
                address.Text = "Из-за коронавируса событие проводится онлайн.";
            }
            else
            {
                address.Text = "Адресс: " + e.Address;
            }
            if (e.DateStart.Equals("02.01.0001 21:30"))
            {
                start.Text   = "Начало: " + "сегодня в " + e.DateStart.Replace("02.01.0001", "");
                address.Text = "Из-за коронавируса событие проводится онлайн.";
            }
            else
            {
                start.Text = "Начало: " + e.DateStart;
            }
        }
示例#13
0
 public static EventInfo ToEventContract(this Data.Event @event)
 {
     return(new EventInfo()
     {
         Id = @event.Id,
         CompanyId = @event.Company.Id,
         CreationTime = @event.CreationTime,
         StartDate = @event.StartDate,
         EndDate = @event.EndDate,
         Location = @event.Location,
         Name = @event.Name,
         Description = @event.Description
     });
 }
        public async Task <IActionResult> OnGetAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Event = await _context.Events.SingleOrDefaultAsync(m => m.Id == id);

            if (Event == null)
            {
                return(NotFound());
            }
            return(Page());
        }
示例#15
0
        public async Task <IActionResult> OnGetAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Event = await _context.Events.Include(e => e.Images).SingleOrDefaultAsync(m => m.Id == id);

            ViewData["ImageId"] = new SelectList(_context.Images, "Id", "Id");
            if (Event == null)
            {
                return(NotFound());
            }
            return(Page());
        }
示例#16
0
 public static ClassModel Create(Data.Event e, string userId) => new ClassModel
 {
     Id                     = e.Id,
     Title                  = e.Title,
     Description            = e.Description,
     SignupHelp             = e.SignupOptions.SignupHelp,
     OpensAt                = e.SignupOptions.SignupOpensAt,
     IsOpen                 = e.IsOpen(),
     RoleSignup             = e.SignupOptions.RoleSignup,
     RoleSignupHelp         = e.SignupOptions.RoleSignupHelp,
     AllowPartnerSignup     = e.SignupOptions.AllowPartnerSignup,
     AllowPartnerSignupHelp = e.SignupOptions.AllowPartnerSignupHelp,
     Signup                 = e.Signups
                              .Select(s => ClassSignupModel.Create(s))
                              .FirstOrDefault(s => s.UserId == userId)
 };
示例#17
0
        public bool TestShouldAutoAccept(int autoAcceptCount, int signupCount, DanceRole role)
        {
            var model = new Data.Event
            {
                SignupOptions = new EventSignupOptions
                {
                    AutoAcceptedSignups = autoAcceptCount
                },
                Signups =
                {
                    GenerateSignups(signupCount)
                }
            };

            return(model.ShouldAutoAccept(role));
        }
示例#18
0
        public EventViewModels EventNotFound()
        {
            // This could break if we have multiple events with the same name
            Data.Event dataEvent = _repository.Get <Data.Event>(x => x.Title.Equals("NOTFOUND", StringComparison.Ordinal));
            if (dataEvent == null)
            {
                // We can't even find the fake event!
                return(null);
            }
            Container_Classes.Event containerEvent = Container_Classes.Event.DataEventToContainerEvent(dataEvent, 0, "NOTFOUND", "NOTFOUND");

            EventViewModels model = new EventViewModels();

            model.Event = containerEvent;

            return(model);
        }
        public async Task <IActionResult> OnPostAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Event = await _context.Events.FindAsync(id);

            if (Event != null)
            {
                _context.Events.Remove(Event);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
示例#20
0
 public static void SetEventStatus(this Data.Event model, string status)
 {
     if (status == "open")
     {
         model.SignupOptions.SignupOpensAt  = TimeProvider.UtcNow;
         model.SignupOptions.SignupClosesAt = null;
     }
     else if (status == "close")
     {
         model.SignupOptions.SignupClosesAt = TimeProvider.UtcNow;
     }
     else if (status == "archive")
     {
         model.SignupOptions.SignupClosesAt = model.SignupOptions.SignupClosesAt ?? TimeProvider.UtcNow;
         model.Archived = true;
     }
 }
示例#21
0
 public static EventModel Create(Data.Event model, IEnumerable <Data.EventSignup> signups)
 {
     return(new()
     {
         Id = model.Id,
         SemesterId = model.SemesterId,
         Title = model.Title,
         Description = model.Description,
         Signups = Statuses
                   .Select(s => (s, signups.Where(x => x.Status == s)))
                   .Select(EventSignupStatusModel.Create)
                   .ToReadOnlyCollection(),
         Archived = model.Archived,
         Type = model.Type,
         RoleSignup = model.SignupOptions.RoleSignup,
         AllowPartnerSignup = model.SignupOptions.AllowPartnerSignup
     });
 }
示例#22
0
        // Converts a Container Object to a Data.Event
        public static Data.Event ContainerEventToDataEvent(Event containerEvent, int category_ID, int type_ID, int owner_ID)
        {
            Data.Event dataEvent = new Data.Event();

            dataEvent.EventID     = containerEvent.ID;
            dataEvent.Category_ID = category_ID;
            dataEvent.Description = containerEvent.Description;
            dataEvent.EndDate     = containerEvent.EndDate;
            dataEvent.Location    = containerEvent.Location;
            dataEvent.Logo_Path   = containerEvent.Logo_Path;
            dataEvent.Owner_ID    = owner_ID;
            dataEvent.StartDate   = containerEvent.StartDate;
            dataEvent.Status      = containerEvent.Status;
            dataEvent.Title       = containerEvent.Title;
            dataEvent.Type_ID     = type_ID;

            return(dataEvent);
        }
示例#23
0
        // Converts a Data.Event from database storage to container object
        public static Event DataEventToContainerEvent(Data.Event dataEvent, int owner_ID, string category, string type)
        {
            Event containerEvent = new Event();

            containerEvent.ID          = dataEvent.EventID;
            containerEvent.Category    = category;
            containerEvent.Description = dataEvent.Description;
            containerEvent.EndDate     = dataEvent.EndDate;
            containerEvent.Location    = dataEvent.Location;
            containerEvent.Owner_ID    = owner_ID;
            containerEvent.Logo_Path   = dataEvent.Logo_Path;
            containerEvent.StartDate   = dataEvent.StartDate;
            containerEvent.Status      = dataEvent.Status;
            containerEvent.Title       = dataEvent.Title;
            containerEvent.Type        = type;

            return(containerEvent);
        }
示例#24
0
        private Data.Event _Map(Models.Event evnt)
        {
            var data = new Data.Event {
                ID          = evnt.Id,
                Title       = evnt.Title,
                StartDate   = evnt.StartDate,
                EndDate     = evnt.EndDate,
                Type_ID     = evnt.Type_ID,
                Description = evnt.Description,
                Owner_ID    = evnt.Owner_ID,
                Logo_Path   = evnt.Logo_Path,
                Location    = evnt.Location,
                Status      = evnt.Status,
                Category_ID = 1
            };

            return(data);
        }
示例#25
0
        private Models.Event _Map(Data.Event source)
        {
            var model = new Models.Event
            {
                Id          = source.ID,
                Title       = source.Title,
                StartDate   = source.StartDate,
                EndDate     = source.EndDate,
                Type_ID     = source.Type_ID,
                Description = source.Description,
                Owner_ID    = source.Owner_ID,
                Logo_Path   = source.Logo_Path,
                Location    = source.Location,
                Status      = source.Status,
                Category_ID = 1,
            };

            return(model);
        }
示例#26
0
 public static void UpdateEvent(this Data.Event entity, EventInputModel model)
 {
     entity.Title       = model.Title;
     entity.Description = model.Description;
     entity.Type        = model.Type;
     entity.SignupOptions.RequiresMembershipFee  = model.RequiresMembershipFee;
     entity.SignupOptions.RequiresTrainingFee    = model.RequiresTrainingFee;
     entity.SignupOptions.RequiresClassesFee     = model.RequiresClassesFee;
     entity.SignupOptions.PriceForMembers        = model.PriceForMembers;
     entity.SignupOptions.PriceForNonMembers     = model.PriceForNonMembers;
     entity.SignupOptions.SignupOpensAt          = GetUtc(model.EnableSignupOpensAt, model.SignupOpensAtDate, model.SignupOpensAtTime);
     entity.SignupOptions.SignupClosesAt         = GetUtc(model.EnableSignupClosesAt, model.SignupClosesAtDate, model.SignupClosesAtTime);
     entity.SignupOptions.SignupHelp             = model.SignupHelp;
     entity.SignupOptions.RoleSignup             = model.RoleSignup;
     entity.SignupOptions.RoleSignupHelp         = model.RoleSignupHelp;
     entity.SignupOptions.AllowPartnerSignup     = model.AllowPartnerSignup;
     entity.SignupOptions.AllowPartnerSignupHelp = model.AllowPartnerSignupHelp;
     entity.SignupOptions.AutoAcceptedSignups    = model.AutoAcceptedSignups;
 }
        public bool CreateEvent(EventBlockCreate model)
        {
            var entity =
                new Data.Event()
            {
                Title       = model.Title,
                IsAllDay    = model.IsAllDay,
                Start       = model.Start,
                End         = model.End,
                Description = model.Description,
                ThemeColor  = model.ThemeColor,
            };

            using (var ctx = new StudyTimeHelperEntities())
            {
                ctx.Event.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
示例#28
0
        public void SetEventStatus_Open()
        {
            using (TemporaryTime.Is(DateTime.UtcNow))
            {
                var model = new Data.Event
                {
                    SignupOptions =
                    {
                        SignupClosesAt = TimeProvider.UtcNow
                    }
                };

                model.SetEventStatus("open");

                model.SignupOptions.SignupOpensAt.ShouldBe(TimeProvider.UtcNow);
                model.SignupOptions.SignupClosesAt.ShouldBeNull();
                model.Archived.ShouldBeFalse();
            }
        }
示例#29
0
        public void SetEventStatus_Archive()
        {
            using (TemporaryTime.Is(DateTime.UtcNow))
            {
                var model = new Data.Event
                {
                    SignupOptions =
                    {
                        SignupOpensAt = TimeProvider.UtcNow.AddDays(-1)
                    }
                };

                model.SetEventStatus("archive");

                model.SignupOptions.SignupOpensAt.ShouldBe(TimeProvider.UtcNow.AddDays(-1));
                model.SignupOptions.SignupClosesAt.ShouldBe(TimeProvider.UtcNow);
                model.Archived.ShouldBeTrue();
            }
        }
示例#30
0
 public static EventModel Create(Data.Event model)
 {
     return(new EventModel
     {
         Id = model.Id,
         Title = model.Title,
         Description = model.Description,
         Signups = Statuses
                   .Select(s => (s, model.Signups.Where(x => x.Status == s)))
                   .Select(EventSignupStatusModel.Create)
                   .ToReadOnlyCollection(),
         Archived = model.Archived,
         SignupOpensAt = model.SignupOptions.SignupOpensAt,
         SignupClosesAt = model.SignupOptions.SignupClosesAt,
         Type = model.Type,
         RoleSignup = model.SignupOptions.RoleSignup,
         AllowPartnerSignup = model.SignupOptions.AllowPartnerSignup,
         IsOpen = model.IsOpen(),
         HasClosed = model.HasClosed()
     });
示例#31
0
        public void CreateEvent(Event event_)
        {
            using (OCCDB db = new OCCDB())
            {
                if (event_.IsDefault)
                {
                    var defaultEvent = db.Events.Where(x => x.IsDefault).FirstOrDefault();
                    if (defaultEvent != null)
                        defaultEvent.IsDefault = false;
                }

                Data.Event e = new Data.Event();

                e.Name = event_.Name;
                e.Description = event_.Description;
                e.TwitterHashTag = event_.TwitterHashTag;
                e.StartTime = event_.StartTime;
                e.EndTime = event_.EndTime;
                e.Location = event_.Location;
                e.Address1 = event_.Address1;
                e.Address2 = event_.Address2;
                e.City = event_.City;
                e.State = event_.State;
                e.Zip = event_.Zip;
                e.IsDefault = event_.IsDefault;
                e.IsSponsorRegistrationOpen = event_.IsSponsorRegistrationOpen;
                e.IsSpeakerRegistrationOpen = event_.IsSpeakerRegistrationOpen;
                e.IsAttendeeRegistrationOpen = event_.IsAttendeeRegistrationOpen;
                e.IsVolunteerRegistrationOpen = event_.IsVolunteerRegistrationOpen;

                db.Events.Add(e);
                db.SaveChanges();
            }
        }