internal BusinessObjectActionReport <DataRepositoryActionStatus> Delete(CMSContentUser cmsContentUser) { BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success); businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsContentUser); if (businessObjectActionReport.ValidationResult.IsValid) { int num = 0; try { using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext()) { num = dataStoreContext.cms_ContentUser_Delete(cmsContentUser.CMSContentId, cmsContentUser.CMSReceivingUserId); } } catch (Exception ex) { _Log.Error("Error at cms_ContentUser_Delete", ex); throw new DataStoreException(ex, true); } if (num != 1) { businessObjectActionReport.Status = DataRepositoryActionStatus.SqlError; _Log.WarnFormat("CMSContentUser {0} was not deleted from the database (ErrorCode: {1}).", DebugUtility.GetObjectString(cmsContentUser), num); } } else { businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed; _Log.WarnFormat("CMSContentUser {0} was not deleted from the database because the validation failed.\nReport: {1}", DebugUtility.GetObjectString(cmsContentUser), businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII)); } return(businessObjectActionReport); }
public void Test_CreateUpdateDeleteContentUser() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); CMSSection section = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random); CMSThread thread = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random); CMSContent content = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random); CMSContentUserManager manager = new CMSContentUserManager(this.DataStore); CMSContentUser record = new CMSContentUser(userBasic, content); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(record); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Delete(this.DataStore, content, userBasic); Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file }
internal BusinessObjectActionReport <DataRepositoryActionStatus> Update(CMSContentUser cmsContentUser) { BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success); businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsContentUser); if (businessObjectActionReport.ValidationResult.IsValid) { int num = 0; DateTime utcNow = DateTime.UtcNow; try { using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext()) { num = dataStoreContext.cms_ContentUser_InsertOrUpdate(cmsContentUser.CMSContentId, cmsContentUser.CMSReceivingUserId); } } catch (Exception ex) { _Log.Error("Error at cms_ContentUser_InsertOrUpdate", ex); throw new DataStoreException(ex, true); } if (num == 0) { businessObjectActionReport.Status = DataRepositoryActionStatus.NoRecordRowAffected; } else { cmsContentUser.DateReceivedUtc = DateTime.UtcNow; } } else { businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed; _Log.WarnFormat("CMSContentUser {0} was not updated at the database because the validation failed.\nReport: {1}", DebugUtility.GetObjectString(cmsContentUser), businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII)); } return(businessObjectActionReport); }