Esempio n. 1
0
 internal void ShouldThrow_When_Objects_Type_IsNotFound(
     EventOne evt,
     EventCatalog sut)
 => FluentActions
 .Invoking(() => sut.GetName(evt))
 .Should()
 .Throw <EventNotRegisteredException>();
Esempio n. 2
0
        public IActionResult GetEvent(int id)
        {
            EventCatalog _event = eventCatalogContext.Eventcatalogs.Find(id);
            var          place  = eventCatalogContext.Places.Find(_event.PlaceId);

            if (_event == null)
            {
                return(NotFound());
            }

            return(Ok(_event));
        }
Esempio n. 3
0
        public IEnumerable <IEvent> GetEventsForCatalog(Catalog catalog)
        {
            List <IEvent> catalogEvents = new List <IEvent>();

            foreach (IEvent ievent in GetAllEvents())
            {
                if (ievent.GetEventType() == EventType.AddCatalog ||
                    ievent.GetEventType() == EventType.UpdateCatalog ||
                    ievent.GetEventType() == EventType.DeleteCatalog)
                {
                    EventCatalog eventCatalog = ievent as EventCatalog;
                    if (eventCatalog.Catalog == catalog)
                    {
                        catalogEvents.Add(eventCatalog);
                    }
                }
            }
            return(catalogEvents);
        }
Esempio n. 4
0
        public async Task <IActionResult> CreateEventAsync([FromBody] EventCatalog Event)
        {
            var item = new EventCatalog
            {
                Id          = Event.Id,
                Name        = Event.Name,
                Description = Event.Description,
                StartDate   = Event.StartDate,
                EndDate     = Event.EndDate,
                Price       = Event.Price,
                ImageURL    = Event.ImageURL,
                PriceType   = Event.PriceType,
                Category    = Event.Category,
                Type        = Event.Type
            };

            _catalogContext.Eventcatalogs.Add(item);
            await _catalogContext.SaveChangesAsync();

            return(Ok(item));
        }
 public void Remove(int i)
 {
     EventCatalog.RemoveAt(i);
 }
 public void Add(Event e)
 {
     EventCatalog.Add(e);
 }
Esempio n. 7
0
        public IActionResult EditEvent(int id, string name, string description, Place place, DateTime?startDate, DateTime?endDate, EventPriceType?eventPriceType, Decimal?price, string imageURL, EventType?eventType, EventCategory?eventCategory, int?ticketCount)
        {
            EventCatalog match = eventCatalogContext.Eventcatalogs.Find(id);

            if (match == null)
            {
                return(NotFound());
            }

            if (name != null && name != match.Name)
            {
                match.Name = name;
            }

            if (description != null && description != match.Description)
            {
                match.Description = description;
            }

            if (place != null && place != match.Place)
            {
                match.Place = place;
            }

            if (startDate != null && startDate != match.StartDate)
            {
                match.StartDate = (DateTime)startDate;
            }

            if (endDate != null && endDate != match.EndDate)
            {
                match.EndDate = (DateTime)endDate;
            }

            if (eventPriceType != null && eventPriceType != match.PriceType)
            {
                match.PriceType = (EventPriceType)eventPriceType;
            }

            if (price != null && price != match.Price)
            {
                match.Price = (Decimal)price;
            }

            if (imageURL != null && imageURL != match.ImageURL)
            {
                match.ImageURL = imageURL;
            }

            if (eventType != null & eventType != match.Type)
            {
                match.Type = (EventType)eventType;
            }

            if (eventCategory != null & eventCategory != match.Category)
            {
                match.Category = (EventCategory)eventCategory;
            }

            if (ticketCount != null && ticketCount != match.InitialTicketCount)
            {
                match.InitialTicketCount = (int)ticketCount;
            }

            eventCatalogContext.SaveChanges();

            return(Ok(match));
        }
Esempio n. 8
0
 internal void ShouldThrow_When_Name_IsNotFound(
     EventCatalog sut)
 => FluentActions
 .Invoking(() => sut.GetEventType("non-existing-name"))
 .Should()
 .Throw <EventNotRegisteredException>();
Esempio n. 9
0
 internal void Should_Resolve_Type_From_Name(
     [Frozen] IReadOnlyDictionary <EventName, Type> mappings,
     EventCatalog sut)
 => sut.GetEventType(mappings.Keys.First())
 .Should()
 .Be(mappings[mappings.Keys.First()]);