private bool CreateDummyANEvents()
        {
            var entities = new List <ANEvent>();

            for (int i = 0; i < 100; i++)
            {
                var en = new ANEvent()
                {
                    Id                  = 0,
                    UpdatedDate         = DateTime.Now,
                    CreatedDate         = DateTime.Now.AddHours((new Random(Guid.NewGuid().GetHashCode())).Next(-20, 20)),
                    ANEventInformations = new List <ANEventInformation>()
                    {
                        new ANEventInformation()
                        {
                            Id          = 0,
                            Description = string.Format("{0:00}", i) + " -- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non sollicitudin elit. Curabitur magna ligula, condimentum sed lacus nec, vulputate cursus sem. Sed a semper felis. Curabitur ligula enim, auctor eget rutrum a, convallis non diam. Vivamus ullamcorper aliquam purus, et euismod justo. Nulla",
                        }
                    }
                };
                entities.Add(en);
            }
            this.ANDBUnitOfWork.ANEventRepository.Save(entities);
            this.ANDBUnitOfWork.Commit();
            return(true);
        }
Esempio n. 2
0
 public static ANEventModel ToModel(ANEvent entity)
 {
     return(entity == null ? null : new ANEventModel()
     {
         Id = entity.Id,
         CreatedDate = entity.CreatedDate,
         Host = new UserModel()
         {
             Id = entity.UserId.GetValueOrDefault()
         },
     });
 }
        public bool CreateANEvent(ANEventModel model)
        {
            var eEvent = new ANEvent();

            eEvent.UserId      = CurrentUser.Id;
            eEvent.CreatedDate = DateTime.Now;
            eEvent.UpdatedDate = DateTime.Now;
            var eInfo = new ANEventInformation();

            eInfo.Title            = model.Information.Title;
            eInfo.StartDate        = model.Information.StartDate;
            eInfo.EndDate          = model.Information.EndDate;
            eInfo.Description      = model.Information.Description;
            eInfo.ShortDescription = model.Information.ShortDescription;
            var eLocation = new ANEventLocation();

            eLocation.GGId    = model.Information.ANEventLocation.GGId;
            eLocation.Address = model.Information.ANEventLocation.Address;
            eLocation.Name    = model.Information.ANEventLocation.Name;
            eLocation.Lat     = model.Information.ANEventLocation.Lat;
            eLocation.Lng     = model.Information.ANEventLocation.Lng;
            var eCategories = model.Categories.Select(x => new Category()
            {
                Id          = x.Id,
                Name        = x.Name,
                Description = x.Description
            }).ToList();

            eInfo.ANEventLocation    = eLocation;
            eInfo.ANEvent            = eEvent;
            eEvent.ANEventCategories = model.Categories.Select(x => new ANEventCategory()
            {
                CategoryId = x.Id
            }).ToList();
            var elstInfo = new List <ANEventInformation>();

            elstInfo.Add(eInfo);
            eEvent.ANEventInformations = elstInfo;
            //ANImage
            var eANEventImage = new ANEventImage()
            {
                ImageId          = model.CoverPhoto.Id,
                ANEventImageType = (int)Common.ANEventImageType.ANEventCoverImage
            };
            var lstANEventImage = new List <ANEventImage>();

            lstANEventImage.Add(eANEventImage);
            eEvent.ANEventImages = lstANEventImage;
            this.ANDBUnitOfWork.ANEventRepository.Save(eEvent);
            this.ANDBUnitOfWork.Commit();
            return(true);
        }