Example #1
0
        public async Task <IActionResult> AddToCart(EventItems productDetails)
        {
            try
            {
                if (productDetails.Id != null)
                {
                    var user    = _identityService.Get(HttpContext.User);
                    var product = new CartItem()
                    {
                        Id         = Guid.NewGuid().ToString(),
                        Quantity   = 1,
                        EventName  = productDetails.Name,
                        PictureUrl = productDetails.PictureURI,
                        UnitPrice  = productDetails.Price,
                        EventId    = productDetails.Id
                    };
                    await _cartService.AddItemToCart(user, product);
                }
            }
            catch (BrokenCircuitException)
            {
                HandleBrokenCircuitException();
            }

            return(RedirectToAction("Index", "Catalog"));
        }
Example #2
0
        public void SetSelectListItems()
        {
            var repo = new DbRepository();

            var events = repo.GetAllEvents();

            foreach (var e in events)
            {
                EventItems.Add(new SelectListItem
                {
                    Text  = e.Name,
                    Value = e.EventId.ToString()
                });
            }

            var beers = repo.GetAllBeers();

            foreach (var beer in beers)
            {
                BeerItems.Add(new SelectListItem
                {
                    Text  = beer.Name,
                    Value = beer.BeerId.ToString()
                });
            }
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance for the <see cref="EventListViewModel" /> class.
        /// </summary>

        public EventListViewModel()
        {
            this.EventItems = new List <EventList>()
            {
                new EventList {
                    ImagePath = App.BaseImageUrl + "Event-Image-two.png", EventMonth = "Dec",
                    EventName = "Build Your Base, New York", EventDate = "24", IsUpcoming = true,
                    EventTime = "2:00 PM - 6:00 PM"
                },
                new EventList {
                    ImagePath = App.BaseImageUrl + "Event-Image.png", EventMonth = "Dec",
                    EventName = "Ignite Music, New York", EventDate = "22", IsPopular = true,
                    EventTime = "7:00 PM - 11:00 PM"
                },
                new EventList {
                    ImagePath = App.BaseImageUrl + "Event-Image-three.png", EventMonth = "Dec",
                    EventName = "John Weds Jane, New York", EventDate = "27", IsUpcoming = true,
                    EventTime = "10:00 AM - 2:00 PM"
                },
                new EventList {
                    ImagePath = App.BaseImageUrl + "Event-Image-one.png", EventMonth = "Dec",
                    EventName = "BigSounds, New York", EventDate = "23", IsPopular = true,
                    EventTime = "9:00 PM - 1:00 PM"
                }
            };

            this.PopularEventItems = EventItems.Where(item => item.IsUpcoming == true).ToList();

            this.UpcomingEventItems = EventItems.Where(item => item.IsPopular == true).ToList();
        }
Example #4
0
        public static List <Job> ParseJobsForPrinter(UsbPrinter printer)
        {
            EventRecord       entry;
            List <EventItems> items      = new List <EventItems>();
            EventItems        eventItems = null;
            EventLogReader    reader     = new EventLogReader(new EventLogQuery("Microsoft-Windows-PrintService/Operational", PathType.LogName));
            uint copies = 0;
            uint jobId  = 0;

            while ((entry = reader.ReadEvent()) != null)
            {
                switch (entry.Id)
                {
                case 805:
                {
                    eventItems = new EventItems();
                    jobId      = Convert.ToUInt32(entry.Properties[0].Value);
                    copies     = Convert.ToUInt32(entry.Properties[7].Value);
                    break;
                }

                case 307:
                {
                    if (jobId == Convert.ToUInt32(entry.Properties[0].Value))
                    {
                        if (eventItems != null)
                        {
                            if (entry.TimeCreated != null)
                            {
                                eventItems.Time = (DateTimeOffset)entry.TimeCreated;
                            }
                            eventItems.TotalPage = Convert.ToUInt32(entry.Properties[7].Value) * copies;
                        }
                    }

                    if (entry.Properties[4].Value.Equals(printer.SystemName))
                    {
                        items.Add(eventItems);
                    }

                    break;
                }
                }
            }

            return(items.Select(item => new Job(item.Time, item.TotalPage, printer)).ToList());
        }
Example #5
0
        private void m_stream_OnProtocol(object sender, XmlElement rp)
        {
            if (rp.Name != "message")
            {
                return;
            }
            PubSubEvent evt = rp["event", URI.PUBSUB_EVENT] as PubSubEvent;

            if (evt == null)
            {
                return;
            }

            EventItems items = evt.GetChildElement <EventItems>();

            if (items == null)
            {
                return;
            }
            if (items.Node != m_node)
            {
                return;
            }

            // OK, it's for us.  Might be a new one or a retraction.
            // Shrug, even if we're sent a mix, it shouldn't hurt anything.

            /*
             * <message from='pubsub.shakespeare.lit' to='*****@*****.**' id='bar'>
             * <event xmlns='http://jabber.org/protocol/pubsub#event'>
             *  <items node='princely_musings'>
             *    <retract id='ae890ac52d0df67ed7cfdf51b644e901'/>
             *  </items>
             * </event>
             * </message>
             */
            foreach (string id in items.GetRetractions())
            {
                m_items.RemoveId(id);
            }

            foreach (PubSubItem item in items.GetItems())
            {
                m_items.Add(item);
            }
        }
        private void m_stream_OnProtocol(object sender, XmlElement rp)
        {
            Message msg = rp as Message;

            if (msg == null)
            {
                return;
            }
            PubSubEvent evt = msg["event", URI.PUBSUB_EVENT] as PubSubEvent;

            if (evt == null)
            {
                return;
            }

            EventItems items = evt.GetChildElement <EventItems>();

            if (items == null)
            {
                return;
            }

            string     node = items.Node;
            JID        from = msg.From.BareJID;
            JIDNode    jn   = new JIDNode(from, node);
            PubSubNode psn  = null;

            if (!m_nodes.TryGetValue(jn, out psn))
            {
                CBHolder holder = null;
                if (!m_callbacks.TryGetValue(node, out holder))
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                                                    "WARNING: notification received for unknown pubsub node: {0}",
                                                    node));
                    return;
                }
                psn               = new PubSubNode(m_stream, from, node, holder.Max);
                psn.OnItemAdd    += holder.FireAdd;
                psn.OnItemRemove += holder.FireRemove;
                m_nodes[jn]       = psn;
            }
            psn.FireItems(items);
        }
Example #7
0
        public static async void Seed(IServiceProvider serviceProvider)
        {
            using var scope         = serviceProvider.CreateScope();
            await using var context = scope.ServiceProvider.GetService <ApplicationDbContext>();

            // It should be uncomment when using UseSqlServer() settings or any other providers.
            // This is should not be used when UseInMemoryDatabase()
            // await context!.Database.MigrateAsync();

            await context !.EventItems.AddAsync(new EventItem
            {
                CreatedAt = DateTime.UtcNow,
                Id        = Guid.Parse("1467a5b9-e61f-82b0-425b-7ec75f5c5029"),
                Level     = "Information",
                Logger    = "SEED",
                Message   = "Seed method some entities successfully save to ApplicationDbContext"
            });

            await context.SaveChangesAsync();
        }
Example #8
0
        internal void FireItems(EventItems items)
        {
            // OK, it's for us.  Might be a new one or a retraction.
            // Shrug, even if we're sent a mix, it shouldn't hurt anything.

            /*
             * <message from='pubsub.shakespeare.lit' to='*****@*****.**' id='bar'>
             * <event xmlns='http://jabber.org/protocol/pubsub#event'>
             *  <items node='princely_musings'>
             *    <retract id='ae890ac52d0df67ed7cfdf51b644e901'/>
             *  </items>
             * </event>
             * </message>
             */
            foreach (string id in items.GetRetractions())
            {
                m_items.RemoveId(id);
            }

            foreach (PubSubItem item in items.GetItems())
            {
                m_items.Add(item);
            }
        }
Example #9
0
        private void Initialize(SchedulesOnDay schedules, MyObservableList <BaseViewItemHomeworkExamGrade> events, MyObservableList <ViewItemHoliday> holidays)
        {
            List <ScheduleItem> schedulesCopied;

            if (schedules == null)
            {
                // Different semester case, so no schedules
                schedulesCopied = new List <ScheduleItem>();
            }
            else
            {
                schedulesCopied = schedules.Where(i => i.EndTime.TimeOfDay > i.StartTime.TimeOfDay).Select(i => new ScheduleItem(this, i)).ToList();
            }

            List <EventItem> eventsCopied = new List <EventItem>();
            List <BaseViewItemHomeworkExam> allDayEvents = new List <ViewItems.BaseViewItems.BaseViewItemHomeworkExam>();

            foreach (var e in events.OfType <BaseViewItemHomeworkExam>())
            {
                if (e.IsDuringDay())
                {
                    eventsCopied.Add(new EventItem(this, e));
                }
                else
                {
                    allDayEvents.Add(e);
                }
            }
            AllDayItems = allDayEvents;

            Holidays    = holidays.ToList();
            HasHolidays = Holidays.Any();
            _cachedHolidayAndAllDayItems = null;

            var schedulesFinal = schedulesCopied.ToArray();
            var eventsFinal    = eventsCopied.ToList();

            ScheduleItems = schedulesFinal;

            // Handle schedule collisions
            while (schedulesCopied.Count > 0)
            {
                var collidingSchedules = new List <ScheduleItem>()
                {
                    schedulesCopied[0]
                };
                schedulesCopied.RemoveAt(0);
                AddColliding(schedulesCopied, collidingSchedules);

                if (collidingSchedules.Count > 1)
                {
                    for (int i = 0; i < collidingSchedules.Count; i++)
                    {
                        collidingSchedules[i].Column       = i;
                        collidingSchedules[i].NumOfColumns = collidingSchedules.Count;
                    }
                }
            }

            // Handle event collisions
            while (eventsCopied.Count > 0)
            {
                var collidingEvents = new List <EventItem>()
                {
                    eventsCopied[0]
                };
                eventsCopied.RemoveAt(0);
                AddColliding(eventsCopied, collidingEvents);

                List <ScheduleItem> scheduleCollisionsWithEvent = new List <ScheduleItem>();

                // If there's a colliding schedule, we collapse
                bool doesCollideWithSchedule = false;
                foreach (var e in collidingEvents)
                {
                    foreach (var s in schedulesFinal)
                    {
                        if (s.CollidesWith(e))
                        {
                            doesCollideWithSchedule = true;
                            scheduleCollisionsWithEvent.Add(s);
                        }
                    }
                }

                if (doesCollideWithSchedule)
                {
                    var firstEvent = collidingEvents[0];
                    firstEvent.IsCollapsedMode = true;
                    foreach (var e in collidingEvents.Skip(1))
                    {
                        firstEvent.AddAdditionalItem(e);
                        eventsFinal.Remove(e);
                    }

                    foreach (var s in scheduleCollisionsWithEvent)
                    {
                        if (firstEvent.AdditionalItems != null)
                        {
                            s.LeftOffset = _spacingWithAdditionalItems;
                        }
                        else
                        {
                            // LeftOffset might have been previously assigned, so make sure we're assigning higher value
                            if (_spacingWhenNoAdditionalItems > s.LeftOffset)
                            {
                                s.LeftOffset = _spacingWhenNoAdditionalItems;
                            }
                        }
                    }
                }
                else if (collidingEvents.Count == 1)
                {
                    // Nothing
                }
                else if (collidingEvents.Count == 2)
                {
                    // Exactly two items
                    collidingEvents[0].NumOfColumns = 2;
                    collidingEvents[1].NumOfColumns = 2;
                    collidingEvents[1].Column       = 1;
                }
                else
                {
                    // More than two items
                    EventItem prev       = null;
                    bool      isLeftSide = true;

                    while (collidingEvents.Count > 0)
                    {
                        var curr = collidingEvents[0];
                        curr.NumOfColumns = 2;
                        collidingEvents.RemoveAt(0);

                        if (prev != null)
                        {
                            if (!isLeftSide)
                            {
                                curr.Column = 1;
                            }

                            // Find out if any items collide with the prev item, and therefore need to become mini-items with the curr item
                            while (collidingEvents.Count > 0)
                            {
                                var next = collidingEvents[0];
                                if (prev.CollidesWith(next))
                                {
                                    collidingEvents.RemoveAt(0);
                                    curr.AddAdditionalItem(next);
                                    eventsFinal.Remove(next);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }

                        // Prev becomes curr
                        prev = curr;

                        // And we switch the side
                        isLeftSide = !isLeftSide;
                    }
                }
            }

            EventItems = eventsFinal.ToArray();

            if (ScheduleItems.Any() || EventItems.Any())
            {
                var min = ScheduleItems.OfType <BaseScheduleItem>().Concat(EventItems.OfType <BaseScheduleItem>()).Min(i => i.StartTime);
                if (min.Minutes == 59 && min.Hours != 23)
                {
                    // So that a task that's due before class (1 min before) doesn't cause an entire hour to be rendered, we adjust 0:59 to the next hour
                    // Note that we exclude incrementing 23:59 since that would make it the next day
                    min = min.Add(TimeSpan.FromMinutes(1));
                }
                StartTime = new TimeSpan(min.Hours, 0, 0);
                EndTime   = new TimeSpan(ScheduleItems.OfType <BaseScheduleItem>().Concat(EventItems.OfType <BaseScheduleItem>()).Max(i => i.EndTime).Hours, 0, 0);
                if (EndTime < StartTime)
                {
                    EndTime = StartTime.Add(TimeSpan.FromHours(1));
                }
            }

            CalculateOffsets();
        }
Example #10
0
        protected override void Perform(GameObject obj, object referenceParent, FieldInfo field)
        {
            if (obj is Ocean)
            {
                if (LotManager.sOceanObject == obj)
                {
                    return;
                }
            }
            else if (obj is Terrain)
            {
                if (Terrain.sTerrain == obj)
                {
                    return;
                }
            }

            if (DereferenceManager.HasBeenDestroyed(obj))
            {
                if (obj is Sim)
                {
                    LotManager.sActorList.Remove(obj as Sim);

                    DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), true, false);
                }
                else
                {
                    GameObjectReference refObj = ObjectLookup.GetReference(new ReferenceWrapper(obj));
                    if (DereferenceManager.Perform(obj, refObj, false, false))
                    {
                        DereferenceManager.Perform(obj, refObj, true, false);

                        ErrorTrap.LogCorrection("Destroyed Object Found: " + obj.GetType());
                    }
                }
                return;
            }

            if (kShowFullReferencing)
            {
                DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), false, true);
            }

            if (obj.InWorld)
            {
                return;
            }

            if (obj.InInventory)
            {
                if (Inventories.ParentInventory(obj) == null)
                {
                    if ((obj.Parent != null) || (Consignment.ContainsKey(obj)))
                    {
                        obj.SetFlags(GameObject.FlagField.InInventory, false);

                        ErrorTrap.LogCorrection("Invalid Inventory Object Unflagged: " + obj.GetType());
                    }
                    else
                    {
                        ErrorTrap.LogCorrection("Invalid Inventory Object Found: " + obj.GetType());
                        ErrorTrap.AddToBeDeleted(obj, true);
                    }
                }

                return;
            }
            else
            {
                if (SharedInventories.ContainsKey(obj.ObjectId))
                {
                    obj.SetFlags(GameObject.FlagField.InInventory, true);

                    ErrorTrap.LogCorrection("Inventory Object Flagged: " + obj.GetType());
                    return;
                }
            }

            if (EventItems.ContainsKey(obj.ObjectId))
            {
                return;
            }

            bool hasParent = false;

            IGameObject parent = obj.Parent;

            while (parent != null)
            {
                hasParent = true;

                if (DereferenceManager.HasBeenDestroyed(parent))
                {
                    ErrorTrap.LogCorrection("Destroyed Parent Object Found: " + parent.GetType());
                    ErrorTrap.AddToBeDeleted(obj, true);

                    hasParent = false;
                    break;
                }

                parent = parent.Parent;
            }

            if (!hasParent)
            {
                ReferenceWrapper refObj = new ReferenceWrapper(obj);

                GameObjectReference reference = ObjectLookup.GetReference(refObj);
                if ((reference != null) && (reference.HasReferences))
                {
                    if (DereferenceManager.Perform(obj, ObjectLookup.GetReference(refObj), false, false))
                    {
                        IScriptProxy proxy = Simulator.GetProxy(obj.ObjectId);
                        if (proxy != null)
                        {
                            IScriptLogic logic = proxy.Target;
                            if (object.ReferenceEquals(logic, obj))
                            {
                                bool log = !sSilentDestroy.ContainsKey(obj.GetType());

                                if (log)
                                {
                                    ErrorTrap.LogCorrection("Out of World Object Found 2: " + obj.GetType());
                                }
                                else
                                {
                                    ErrorTrap.DebugLogCorrection("Out of World Object Found 3: " + obj.GetType());
                                }

                                ErrorTrap.AddToBeDeleted(obj, log);
                            }
                            else
                            {
                                ErrorTrap.DebugLogCorrection("Out of World Object Found 4: " + obj.GetType());
                                ErrorTrap.DebugLogCorrection("Out of World Object Found 5: " + logic.GetType());
                            }
                        }
                        else
                        {
                            DereferenceManager.Perform(obj, ObjectLookup.GetReference(refObj), true, false);
                        }
                    }
                }
                else
                {
                    ErrorTrap.LogCorrection("Out of World Object Found 1: " + obj.GetType());
                    ErrorTrap.AddToBeDeleted(obj, true);
                }
            }
        }
Example #11
0
 public void DeleteEvent(EventDefinition item)
 {
     Context.Events.Remove(item);
     Context.SaveChanges();
     EventItems.Remove(item);
 }