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); }
public static ANEventInformationModel ToModel(ANEventInformation entity) { return(entity == null ? null : new ANEventInformationModel() { Id = entity.Id, ANEvent = new ANEventModel() { Id = entity.ANEventId.GetValueOrDefault() }, Title = entity.Title, Description = entity.Description, ShortDescription = entity.ShortDescription, EventLocation = entity.EventLocation, StartDate = entity.StartDate, EndDate = entity.EndDate }); }