/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="templateID"></param> /// <returns></returns> public OperationResult<OperationResults, CuratedGallery> CreateGallery(string name, int? templateID = null) { var rslt = new OperationResult<OperationResults, CuratedGallery>(); using (var context = this.CreateMainContext()) { var template = templateID.HasValue ? context.GalleryTemplateRecords.Where(x => x.ID == templateID.Value).SingleOrDefault() : context.GalleryTemplateRecords.Where(x => x.IsDefault).SingleOrDefault(); if (template == null) throw new Exception("Template was not found"); var gallery = new CuratedGalleryRecord() { DateCreated = DateTime.UtcNow, Enabled = true, Name = name, TemplateID = template.ID, StatusID = (int)CuratedGalleryStatuses.UnPublished }; context.CuratedGalleryRecords.InsertOnSubmit(gallery); context.SubmitChanges(); rslt.Result = OperationResults.Success; rslt.Output = this.ObjectMapper.DoMapping<CuratedGallery>(gallery); } return rslt; }
private void detach_CuratedGalleryRecords(CuratedGalleryRecord entity) { this.SendPropertyChanging(); entity.CuratedGalleryStatusRecord = null; }
private void attach_CuratedGalleryRecords(CuratedGalleryRecord entity) { this.SendPropertyChanging(); entity.GalleryTemplateRecord = this; }
partial void DeleteCuratedGalleryRecord(CuratedGalleryRecord instance);
partial void UpdateCuratedGalleryRecord(CuratedGalleryRecord instance);
partial void InsertCuratedGalleryRecord(CuratedGalleryRecord instance);
private void detach_CuratedGalleryRecords(CuratedGalleryRecord entity) { this.SendPropertyChanging(); entity.AdminUserMembershipRecord = null; }
protected CuratedGallery Convert(CuratedGalleryRecord record) { MappingData md = new MappingData(new string[] { Utils.GetPropertyName<CuratedGallery, AdminUserInfo>(x => x.Editor) }); md.PropertiesMapping.Add(new MappingDataItem(Utils.GetPropertyName<CuratedGalleryRecord, short>(x => x.StatusID), Utils.GetPropertyName<CuratedGallery, CuratedGalleryStatuses>(x => x.Status), x => x.ToEnum<CuratedGalleryStatuses>())); md.PropertiesMapping.Add(new MappingDataItem(Utils.GetPropertyName<CuratedGalleryRecord, DateTime>(x => x.DateCreated), null, x => ((DateTime)x).ToLocalTime())); md.PropertiesMapping.Add(new MappingDataItem(Utils.GetPropertyName<CuratedGalleryRecord, DateTime?>(x => x.DateModified), null, x => (x == null ? (DateTime?)null : ((DateTime)x).ToLocalTime()))); return this.ObjectMapper.DoMapping<CuratedGallery>(record, md); }