public static ANEventLocationModel ToModel(ANEventLocation entity) { return(entity == null ? null : new ANEventLocationModel() { Id = entity.Id, Address = entity.Address, GGId = entity.GGId, Lat = entity.Lat, Lng = entity.Lng, Name = entity.Name }); }
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); }