コード例 #1
0
        public List <Picture> AddPicturesToEvent(List <Picture> pictures)
        {
            var picturesStorageModel = pictures.Select(p => new PictureStorageModel()
            {
                EventId     = p.EventId,
                Description = p.Description,
                Link        = p.Link.ToString()
            }).ToList();

            _culturalHubContext.Pictures.AddRange(picturesStorageModel);

            _culturalHubContext.SaveChanges();

            return(pictures);
        }
コード例 #2
0
        //public IEnumerable<Event> GetEvents()
        //{
        //    return _culturalHubContext.Events
        //        .Where(e => e.Deleted == null)
        //        .Select(e =>
        //            new Event(new EventId(e.Id),
        //                new ClientId(e.ClientId),
        //                new EventTitle(e.Title),
        //                new EventDescription(e.Description),
        //                new Location(e.LocationAddress, (LocationType) e.LocationType),
        //                new EventDate(e.StartsAt.Year, e.StartsAt.Month, e.StartsAt.Day, e.StartsAt.Hour,
        //                    e.StartsAt.Minute),
        //                new EventDate(e.EndsAt.Year, e.EndsAt.Month, e.EndsAt.Day, e.EndsAt.Hour, e.EndsAt.Minute),
        //                (EventType) e.Type,
        //                (Audience) e.Audience,
        //                new EventPublishDate(e.PublishDate),
        //                e.IsActive)
        //        );
        //}

        //public List<Event> GetEvents()
        //{
        //    return _culturalHubContext.Events
        //        .Where(e => e.Deleted == null)
        //        .Select(e =>
        //            new Event(new EventId(e.Id),
        //                new ClientId(e.ClientId),
        //                new EventTitle(e.Title),
        //                new EventDescription(e.Description),
        //                new Location(e.LocationAddress, (LocationType) e.LocationType),
        //                new EventDate(e.StartsAt.Year, e.StartsAt.Month, e.StartsAt.Day, e.StartsAt.Hour,
        //                    e.StartsAt.Minute),
        //                new EventDate(e.EndsAt.Year, e.EndsAt.Month, e.EndsAt.Day, e.EndsAt.Hour, e.EndsAt.Minute),
        //                (EventType) e.Type,
        //                (Audience) e.Audience,
        //                new EventPublishDate(e.PublishDate),
        //                e.IsActive)
        //        )
        //        .ToList();
        //}

        public Event AddEvent(Event e)
        {
            var eventStorageModel = new EventStorageModel
            {
                Id              = e.Id.Value,
                ClientId        = e.ClientId.Value,
                Title           = e.Title.TitleValue,
                StartsAt        = e.StartsAt.Value,
                Description     = e.Description.DescriptionValue,
                EndsAt          = e.EndsAt.Value,
                Audience        = (int)e.Audience,
                Type            = (int)e.Type,
                PublishDate     = e.PublishDate.Value,
                IsActive        = e.IsActive,
                LocationAddress = e.Location.Address,
                LocationType    = (int)e.Location.Type
            };

            _culturalHubContext.Events.Add(eventStorageModel);

            _culturalHubContext.SaveChanges();

            return(e);
        }