Ejemplo n.º 1
0
		public void Create()
		{
			var generator = new RandomObjectGenerator();
			var profileId = generator.Generate<string>();

			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => Mock.Of<IEntities>());

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var user = new DataPortal<User>().Create(profileId);

				Assert.IsNull(user.BirthDate, user.GetPropertyName(_ => _.BirthDate));
				Assert.AreEqual(string.Empty, user.EmailAddress, user.GetPropertyName(_ => _.EmailAddress));
				Assert.AreEqual(string.Empty, user.FirstName, user.GetPropertyName(_ => _.FirstName));
				Assert.AreEqual(string.Empty, user.Gender, user.GetPropertyName(_ => _.Gender));
				Assert.AreEqual(string.Empty, user.LastName, user.GetPropertyName(_ => _.LastName));
				Assert.AreEqual(string.Empty, user.PostalCode, user.GetPropertyName(_ => _.PostalCode));
				Assert.AreEqual(string.Empty, user.ProfileAuthToken, user.GetPropertyName(_ => _.ProfileAuthToken));
				Assert.AreEqual(profileId, user.ProfileID, user.GetPropertyName(_ => _.ProfileID));
				Assert.IsNull(user.UserID, user.GetPropertyName(_ => _.UserID));
				Assert.AreEqual(string.Empty, user.UserName, user.GetPropertyName(_ => _.UserName));
				Assert.IsNull(user.UserRoleID, user.GetPropertyName(_ => _.UserRoleID));

				user.BrokenRulesCollection.AssertRuleCount(2);
				user.BrokenRulesCollection.AssertRuleCount(User.EmailAddressProperty, 1);
				user.BrokenRulesCollection.AssertValidationRuleExists<RequiredAttribute>(
					User.EmailAddressProperty, true);
				user.BrokenRulesCollection.AssertRuleCount(User.UserNameProperty, 1);
				user.BrokenRulesCollection.AssertValidationRuleExists<RequiredAttribute>(
					User.UserNameProperty, true);
			}
		}
    public void IAuthorizeDataPortal_Implementation_DoesNotAllow_Creation()
    {
      var context = GetContext();

      //setup for the test
      SetAppSettingValueCmd
        .ExecuteCommand(
        "CslaAuthorizationProvider",
        "Csla.Testing.Business.DataPortal.DontAuthorizeDataPortalStub, Csla.Testing.Business",
        (o, e) =>
          {
            //actual test
            var dp = new DataPortal<TestBO>();
            dp.CreateCompleted += ((sender, e1) =>
             {
               context.Assert.IsNotNull(e1.Error);
               //TODO: perhaps check to assure that exception type is Csla.Security.SecurityException
               //context.Assert.IsTrue(((Csla.DataPortalException)(e1.Error)).ErrorInfo.InnerError.ExceptionTypeName=="Csla.Security.SecurityException");
               context.Assert.Success();
             });
            dp.BeginCreate();
          });

      context.Complete();
    }
        public static void GetProfileList(System.String username, EventHandler<DataPortalResult<ProfileList>> handler)
        {
            var criteria = new ProfileCriteria { Username = username };

            var dp = new DataPortal<ProfileList>();
            dp.FetchCompleted += handler;
            dp.BeginFetch(criteria);
        }
Ejemplo n.º 4
0
 public static void Fetch(Guid id, Action<ReadOnlyPerson, Exception> completed)
 {
     Csla.DataPortalClient.WcfProxy.DefaultUrl = DataPortalUrl;
       DataPortal<ReadOnlyPerson> dp = new DataPortal<ReadOnlyPerson>();
       dp.FetchCompleted += (o, e) =>
       {
     if (completed != null)
       completed(e.Object, e.Error);
       };
       dp.BeginFetch(new SingleCriteria<ReadOnlyPerson, Guid>(id));
 }
Ejemplo n.º 5
0
 public OperationResult LoadReportDataSet(string serviceName, string connectionName, DataSet dataSet, string[] tableNames, string commandText, params object[] parameterValues)
 {
     try
     {
         DataPortal portal = new DataPortal();
         return portal.LoadReportDataSet(serviceName, connectionName, dataSet, tableNames, commandText, parameterValues);
     }
     catch (Exception ex)
     {
         return new OperationResult() { Message = ex.Message };
     }
 }
Ejemplo n.º 6
0
		public void Create()
		{
			var generator = new RandomObjectGenerator();
			var userId = generator.Generate<int>();

			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => Mock.Of<IEntities>());

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var poll = new DataPortal<Poll>().Create(userId);

				Assert.IsNull(poll.PollAdminRemovedFlag, poll.GetPropertyName(_ => _.PollAdminRemovedFlag));
				Assert.IsNull(poll.PollCategoryID, poll.GetPropertyName(_ => _.PollCategoryID));
				Assert.IsNull(poll.PollDateRemoved, poll.GetPropertyName(_ => _.PollDateRemoved));
				Assert.IsNull(poll.PollDeletedDate, poll.GetPropertyName(_ => _.PollDeletedDate));
				Assert.IsNull(poll.PollDeletedFlag, poll.GetPropertyName(_ => _.PollDeletedFlag));
				Assert.AreEqual(string.Empty, poll.PollDescription, poll.GetPropertyName(_ => _.PollDescription));
				Assert.IsNull(poll.PollEndDate, poll.GetPropertyName(_ => _.PollEndDate));
				Assert.IsNull(poll.PollID, poll.GetPropertyName(_ => _.PollID));
				Assert.AreEqual(string.Empty, poll.PollImageLink, poll.GetPropertyName(_ => _.PollImageLink));
				Assert.IsNull(poll.PollMaxAnswers, poll.GetPropertyName(_ => _.PollMaxAnswers));
				Assert.IsNull(poll.PollMinAnswers, poll.GetPropertyName(_ => _.PollMinAnswers));
				Assert.AreEqual(string.Empty, poll.PollQuestion, poll.GetPropertyName(_ => _.PollQuestion));
				Assert.IsNull(poll.PollStartDate, poll.GetPropertyName(_ => _.PollStartDate));
				Assert.AreEqual(userId, poll.UserID, poll.GetPropertyName(_ => _.UserID));
				Assert.AreEqual(0, poll.PollOptions.Count, poll.GetPropertyName(_ => _.PollOptions));

				poll.BrokenRulesCollection.AssertRuleCount(7);
				poll.BrokenRulesCollection.AssertRuleCount(Poll.PollStartDateProperty, 1);
				poll.BrokenRulesCollection.AssertValidationRuleExists<RequiredAttribute>(
					Poll.PollStartDateProperty, true);
				poll.BrokenRulesCollection.AssertRuleCount(Poll.PollEndDateProperty, 1);
				poll.BrokenRulesCollection.AssertValidationRuleExists<RequiredAttribute>(
					Poll.PollEndDateProperty, true);
				poll.BrokenRulesCollection.AssertRuleCount(Poll.PollCategoryIDProperty, 1);
				poll.BrokenRulesCollection.AssertValidationRuleExists<RequiredAttribute>(
					Poll.PollCategoryIDProperty, true);
				poll.BrokenRulesCollection.AssertRuleCount(Poll.PollQuestionProperty, 1);
				poll.BrokenRulesCollection.AssertValidationRuleExists<RequiredAttribute>(
					Poll.PollQuestionProperty, true);
				poll.BrokenRulesCollection.AssertRuleCount(Poll.PollMinAnswersProperty, 1);
				poll.BrokenRulesCollection.AssertValidationRuleExists<RequiredAttribute>(
					Poll.PollMinAnswersProperty, true);
				poll.BrokenRulesCollection.AssertRuleCount(Poll.PollMaxAnswersProperty, 1);
				poll.BrokenRulesCollection.AssertValidationRuleExists<RequiredAttribute>(
					Poll.PollMaxAnswersProperty, true);
				poll.BrokenRulesCollection.AssertRuleCount(Poll.PollOptionsProperty, 1);
				poll.BrokenRulesCollection.AssertBusinessRuleExists<PollOptionsRule>(
					Poll.PollOptionsProperty, true);
			}
		}
Ejemplo n.º 7
0
		public void Insert()
		{
			var generator = new RandomObjectGenerator();
			var birthDate = generator.Generate<DateTime>();
			var emailAddress = generator.Generate<string>();
			var firstName = generator.Generate<string>();
			var gender = generator.Generate<string>();
			var lastName = generator.Generate<string>();
			var postalCode = generator.Generate<string>();
			var profileAuthToken = generator.Generate<string>();
			var profileId = generator.Generate<string>();
			var userId = generator.Generate<int>();
			var userName = generator.Generate<string>();
			var userRoleId = generator.Generate<int>();

			var users = new InMemoryDbSet<MVUser>();
			var entities = new Mock<IEntities>();
			entities.Setup(_ => _.MVUsers)
				.Returns(users);
			entities.Setup(_ => _.SaveChanges()).Callback(() => users.Local[0].UserID = userId);
			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => entities.Object);

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var user = new DataPortal<User>().Create(profileId);
				user.BirthDate = birthDate;
				user.EmailAddress = emailAddress;
				user.FirstName = firstName;
				user.Gender = gender;
				user.LastName = lastName;
				user.PostalCode = postalCode;
				user.ProfileAuthToken = profileAuthToken;
				user.UserName = userName;
				user.UserRoleID = userRoleId;
				user = user.Save();

				Assert.AreEqual(birthDate, user.BirthDate, user.GetPropertyName(_ => _.BirthDate));
				Assert.AreEqual(emailAddress, user.EmailAddress, user.GetPropertyName(_ => _.EmailAddress));
				Assert.AreEqual(firstName, user.FirstName, user.GetPropertyName(_ => _.FirstName));
				Assert.AreEqual(gender, user.Gender, user.GetPropertyName(_ => _.Gender));
				Assert.AreEqual(lastName, user.LastName, user.GetPropertyName(_ => _.LastName));
				Assert.AreEqual(postalCode, user.PostalCode, user.GetPropertyName(_ => _.PostalCode));
				Assert.AreEqual(profileAuthToken, user.ProfileAuthToken, user.GetPropertyName(_ => _.ProfileAuthToken));
				Assert.AreEqual(userId, user.UserID, user.GetPropertyName(_ => _.UserID));
				Assert.AreEqual(userName, user.UserName, user.GetPropertyName(_ => _.UserName));
				Assert.AreEqual(userRoleId, user.UserRoleID, user.GetPropertyName(_ => _.UserRoleID));
			}
		}
Ejemplo n.º 8
0
 public static void GetProductCategories(EventHandler<DataPortalResult<ProductCategories>> callback)
 {
   if (_cache != null)
   {
     callback(null, new DataPortalResult<ProductCategories>(_cache, null, null));
   }
   else
   {
     var dp = new DataPortal<ProductCategories>();
     dp.FetchCompleted += (o, e) =>
     {
       _cache = e.Object;
       callback(dp, e);
     };
     dp.BeginFetch();
   }
 }
Ejemplo n.º 9
0
        public void IAuthorizeDataPortal_Implementation_Allows_Creation()
        {
            var context = GetContext();

              //setup for the test
              SetAppSettingValueCmd
            .ExecuteCommand(
            "CslaAuthorizationProvider",
            "Csla.Testing.Business.DataPortal.AuthorizeDataPortalStub, Csla.Testing.Business",
            (o, e) =>
              {
            //actual test
            var dp = new DataPortal<TestBO>();
            dp.CreateCompleted += ((sender, e1) =>
             {
               context.Assert.IsNull(e1.Error);
               context.Assert.Success();
             });
            dp.BeginCreate();
              });

              context.Complete();
        }
Ejemplo n.º 10
0
 internal static void GetSLWindowsIdentity(EventHandler<DataPortalResult<SLWindowsIdentity>> completed)
 {
   DataPortal<SLWindowsIdentity> dp = new DataPortal<SLWindowsIdentity>();
   dp.FetchCompleted += completed;
   dp.BeginFetch();
 }
Ejemplo n.º 11
0
    public byte[] Delete(byte[] requestData)
    {
      DeleteRequest request = (DeleteRequest)Deserialize(requestData);

      DataPortal portal = new DataPortal();
      object result;
      try
      {
        result = portal.Delete(request.ObjectType, request.Criteria, request.Context);
      }
      catch (Exception ex)
      {
        result = ex;
      }
      return Serialize(result);
    }
Ejemplo n.º 12
0
 public static T Get(int criteria)
 {
     return(DataPortal.FetchChild <T>(criteria));
 }
 /// <summary>
 /// Factory method. Loads a <see cref="G05_CountryColl"/> collection, based on given parameters.
 /// </summary>
 /// <param name="parent_SubContinent_ID">The Parent_SubContinent_ID parameter of the G05_CountryColl to fetch.</param>
 /// <returns>A reference to the fetched <see cref="G05_CountryColl"/> collection.</returns>
 internal static G05_CountryColl GetG05_CountryColl(int parent_SubContinent_ID)
 {
     return(DataPortal.FetchChild <G05_CountryColl>(parent_SubContinent_ID));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Factory method. Asynchronously deletes a <see cref="DocClass"/> object, based on given parameters.
 /// </summary>
 /// <param name="docClassID">The DocClassID of the DocClass to delete.</param>
 /// <param name="callback">The completion callback method.</param>
 public static void DeleteDocClass(int docClassID, EventHandler <DataPortalResult <DocClass> > callback)
 {
     DataPortal.BeginDelete <DocClass>(docClassID, callback);
 }
		public void CreateWhenPollIsDeleted()
		{
			var now = DateTime.UtcNow;
			var generator = new RandomObjectGenerator();
			var userId = generator.Generate<int>();

			var poll = EntityCreator.Create<MVPoll>(_ =>
			{
				_.PollDeletedFlag = true;
				_.PollStartDate = now.AddDays(-2);
				_.PollEndDate = now.AddDays(2);
				_.PollMinAnswers = 2;
				_.PollMaxAnswers = 3;
			});

			poll.MVPollOptions = new List<MVPollOption> 
			{ 
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>()
			};

			var category = EntityCreator.Create<MVCategory>(_ => _.CategoryID = poll.PollCategoryID);

			var entities = new Mock<IEntities>(MockBehavior.Strict);
			entities.Setup(_ => _.MVPolls)
				.Returns(new InMemoryDbSet<MVPoll> { poll });
			entities.Setup(_ => _.MVPollSubmissions)
				.Returns(new InMemoryDbSet<MVPollSubmission>());
			entities.Setup(_ => _.MVCategories)
				.Returns(new InMemoryDbSet<MVCategory> { category });
			entities.Setup(_ => _.Dispose());

			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => entities.Object);

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var submission = new DataPortal<PollSubmission>().Create(
					new PollSubmissionCriteria(poll.PollID, userId));
				submission.BrokenRulesCollection.AssertRuleCount(PollSubmission.PollDeletedFlagProperty, 1);
				submission.BrokenRulesCollection.AssertBusinessRuleExists<PollSubmissionPollDeletedFlagRule>(
					PollSubmission.PollDeletedFlagProperty, true);
			}

			entities.VerifyAll();
		}
 /// <summary>
 /// Factory method. Loads a <see cref="G09_Region_Child"/> object, based on given parameters.
 /// </summary>
 /// <param name="region_ID1">The Region_ID1 parameter of the G09_Region_Child to fetch.</param>
 /// <returns>A reference to the fetched <see cref="G09_Region_Child"/> object.</returns>
 internal static G09_Region_Child GetG09_Region_Child(int region_ID1)
 {
     return(DataPortal.FetchChild <G09_Region_Child>(region_ID1));
 }
Ejemplo n.º 17
0
 public static GRIdentity GetIdentity(string userName, string password)
 {
     return(DataPortal.Fetch <GRIdentity>(new UsernameCriteria(userName, password)));
 }
Ejemplo n.º 18
0
 public static RoadmapGroupList GetRoadmapGroups()
 {
     return(DataPortal.Fetch <RoadmapGroupList>());
 }
Ejemplo n.º 19
0
 public static RoadmapGroupList GetRoadmapGroups(string filter)
 {
     return(DataPortal.Fetch <RoadmapGroupList>(filter));
 }
Ejemplo n.º 20
0
 public static GRIdentity GetIdentity()
 {
     return(DataPortal.Fetch <GRIdentity>());
 }
Ejemplo n.º 21
0
 public static GRIdentity GetIdentity(Guid IdPerfilUsuario)
 {
     return(DataPortal.Fetch <GRIdentity>(IdPerfilUsuario));
 }
Ejemplo n.º 22
0
 internal static GRIdentity GetIdentity(FiltroUsuario criteria)
 {
     return(DataPortal.Fetch <GRIdentity>(criteria));
 }
Ejemplo n.º 23
0
 public static void GetProductEdit(int id, EventHandler<DataPortalResult<ProductEdit>> callback)
 {
   var dp = new DataPortal<ProductEdit>();
   dp.FetchCompleted += callback;
   dp.BeginFetch(new SingleCriteria<ProductEdit, int>(id));
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Factory method. Loads a <see cref="C07Level1111ReChild"/> object, based on given parameters.
 /// </summary>
 /// <param name="cLarentID2">The CLarentID2 parameter of the C07Level1111ReChild to fetch.</param>
 /// <returns>A reference to the fetched <see cref="C07Level1111ReChild"/> object.</returns>
 internal static C07Level1111ReChild GetC07Level1111ReChild(int cLarentID2)
 {
     return(DataPortal.FetchChild <C07Level1111ReChild>(cLarentID2));
 }
Ejemplo n.º 25
0
 public static Inventory NewInventory()
 {
     return(DataPortal.CreateChild <Inventory>());
 }
Ejemplo n.º 26
0
 public static GRIdentity GetIdentity(string userName, string passWord, string Dominio)
 {
     return(DataPortal.Fetch <GRIdentity>(new FiltroGRomero(userName, passWord, Dominio)));
 }
 /// <summary>
 /// Factory method. Creates a new <see cref="G05_CountryColl"/> collection.
 /// </summary>
 /// <returns>A reference to the created <see cref="G05_CountryColl"/> collection.</returns>
 internal static G05_CountryColl NewG05_CountryColl()
 {
     return(DataPortal.CreateChild <G05_CountryColl>());
 }
 /// <summary>
 /// Factory method. Creates a new <see cref="F11_City_Child"/> object.
 /// </summary>
 /// <returns>A reference to the created <see cref="F11_City_Child"/> object.</returns>
 internal static F11_City_Child NewF11_City_Child()
 {
     return(DataPortal.CreateChild <F11_City_Child>());
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Factory method. Asynchronously loads a <see cref="DocClass"/> object, based on given parameters.
 /// </summary>
 /// <param name="docClassID">The DocClassID parameter of the DocClass to fetch.</param>
 /// <param name="callback">The completion callback method.</param>
 public static void GetDocClass(int docClassID, EventHandler <DataPortalResult <DocClass> > callback)
 {
     DataPortal.BeginFetch <DocClass>(docClassID, callback);
 }
 public static ROSecurityOrganisationProtectedAreaGroupUserList GetROSecurityOrganisationProtectedAreaGroupUserList()
 {
     return(DataPortal.Fetch <ROSecurityOrganisationProtectedAreaGroupUserList>(new Criteria()));
 }
 public static ROSecurityOrganisationProtectedAreaGroupUserList GetROSecurityOrganisationProtectedAreaGroupUserList(int?UserID, int?OrganisationID, int?ProtectedAreaID)
 {
     return(DataPortal.Fetch <ROSecurityOrganisationProtectedAreaGroupUserList>(new Criteria(UserID, OrganisationID, ProtectedAreaID)));
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Factory method. Creates a new <see cref="B03Level11ReChild"/> object.
 /// </summary>
 /// <returns>A reference to the created <see cref="B03Level11ReChild"/> object.</returns>
 internal static B03Level11ReChild NewB03Level11ReChild()
 {
     return(DataPortal.CreateChild <B03Level11ReChild>());
 }
		public void Insert()
		{
			var now = DateTime.UtcNow;
			var generator = new RandomObjectGenerator();
			var userId = generator.Generate<int>();

			var poll = EntityCreator.Create<MVPoll>(_ =>
			{
				_.PollDeletedFlag = false;
				_.PollStartDate = now.AddDays(-2);
				_.PollEndDate = now.AddDays(2);
				_.PollMinAnswers = 2;
				_.PollMaxAnswers = 3;
			});

			poll.MVPollOptions = new List<MVPollOption> 
			{ 
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>()
			};

			var category = EntityCreator.Create<MVCategory>(_ => _.CategoryID = poll.PollCategoryID);

			var polls = new InMemoryDbSet<MVPoll> { poll };
			var submissions = new InMemoryDbSet<MVPollSubmission>();
			var responses = new InMemoryDbSet<MVPollResponse>();

			var saveChangesCount = 0;
			var submissionId = generator.Generate<int>();

			var entities = new Mock<IEntities>(MockBehavior.Strict);
			entities.Setup(_ => _.MVPolls).Returns(polls);
			entities.Setup(_ => _.MVPollSubmissions).Returns(submissions);
			entities.Setup(_ => _.MVPollResponses).Returns(responses);
			entities.Setup(_ => _.MVCategories)
				.Returns(new InMemoryDbSet<MVCategory> { category });
			entities.Setup(_ => _.SaveChanges()).Callback(() =>
				{
					if (saveChangesCount == 0)
					{
						submissions.Local[0].PollSubmissionID = submissionId;
					}

					saveChangesCount++;
				}).Returns(1);
			entities.Setup(_ => _.Dispose());

			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => entities.Object);

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var criteria = new PollSubmissionCriteria(poll.PollID, userId);
				var submission = new DataPortal<PollSubmission>().Create(criteria);

				submission.Responses[1].IsOptionSelected = true;
				submission.Responses[3].IsOptionSelected = true;

				submission = submission.Save();

				Assert.AreEqual(1, submissions.Local.Count, submissions.GetPropertyName(_ => _.Local.Count));
				Assert.AreEqual(submissionId, submission.PollSubmissionID, submission.GetPropertyName(_ => _.PollSubmissionID));
				Assert.AreEqual(4, responses.Local.Count, responses.GetPropertyName(_ => _.Local.Count));
				Assert.IsFalse(responses.Local[0].OptionSelected, responses.GetPropertyName(_ => _.Local[0].OptionSelected));
				Assert.IsTrue(responses.Local[1].OptionSelected, responses.GetPropertyName(_ => _.Local[1].OptionSelected));
				Assert.IsFalse(responses.Local[2].OptionSelected, responses.GetPropertyName(_ => _.Local[2].OptionSelected));
				Assert.IsTrue(responses.Local[3].OptionSelected, responses.GetPropertyName(_ => _.Local[3].OptionSelected));
			}

			entities.VerifyAll();
		}
Ejemplo n.º 34
0
 /// <summary>
 /// Update a business object.
 /// </summary>
 /// <param name="obj">Business object to update.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 public DataPortalResult Update(object obj, DataPortalContext context)
 {
     Server.DataPortal portal = new DataPortal();
     return(portal.Update(obj, context, true).Result);
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Factory method. Loads a <see cref="DocumentList"/> collection, based on given parameters.
 /// </summary>
 /// <param name="folderId">The FolderId parameter of the DocumentList to fetch.</param>
 /// <returns>A reference to the fetched <see cref="DocumentList"/> collection.</returns>
 public static DocumentList GetDocumentList(int folderId)
 {
     return(DataPortal.Fetch <DocumentList>(folderId));
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Delete a business object.
 /// </summary>
 /// <param name="objectType">Type of business object to create.</param>
 /// <param name="criteria">Criteria object describing business object.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 public DataPortalResult Delete(Type objectType, object criteria, DataPortalContext context)
 {
     Server.DataPortal portal = new DataPortal();
     return(portal.Delete(objectType, criteria, context, true).Result);
 }
Ejemplo n.º 37
0
        public static void GetOrder(string uniqueId, EventHandler<DataPortalResult<Order>> handler)
        {
            var criteria = new OrderCriteria{UserId = uniqueId};
            

            var dp = new DataPortal< Order >();
            dp.FetchCompleted += handler;
            dp.BeginFetch(criteria);
        }
 /// <summary>
 /// Factory method. Creates a new <see cref="E09_Region_Child"/> object.
 /// </summary>
 /// <returns>A reference to the created <see cref="E09_Region_Child"/> object.</returns>
 internal static E09_Region_Child NewE09_Region_Child()
 {
     return(DataPortal.CreateChild <E09_Region_Child>());
 }
Ejemplo n.º 39
0
    public byte[] Update(byte[] requestData)
    {
      UpdateRequest request = (UpdateRequest)Deserialize(requestData);

      DataPortal portal = new DataPortal();
      object result;
      try
      {
        result = portal.Update(request.Object, request.Context);
      }
      catch (Exception ex)
      {
        result = ex;
      }
      return Serialize(result);
    }
Ejemplo n.º 40
0
 /// <summary>
 /// Get an existing business object.
 /// </summary>
 /// <param name="objectType">Type of business object to retrieve.</param>
 /// <param name="criteria">Criteria object describing business object.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context)
 {
     Server.DataPortal portal = new DataPortal();
       return portal.Fetch(objectType, criteria, context, true).Result;
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Factory method. Creates a new <see cref="B09_Region_ReChild"/> object.
 /// </summary>
 /// <returns>A reference to the created <see cref="B09_Region_ReChild"/> object.</returns>
 internal static B09_Region_ReChild NewB09_Region_ReChild()
 {
     return(DataPortal.CreateChild <B09_Region_ReChild>());
 }
Ejemplo n.º 42
0
		public void Insert()
		{
			var generator = new RandomObjectGenerator();
			var pollAdminRemoveFlag = generator.Generate<bool>();
			var pollCategoryId = generator.Generate<int>();
			var pollDateRemoved = generator.Generate<DateTime>();
			var pollDeletedDate = generator.Generate<DateTime>();
			var pollDeletedFlag = generator.Generate<bool>();
			var pollDescription = generator.Generate<string>();
			var pollId = generator.Generate<int>();
			var pollImageLink = generator.Generate<string>();
			short pollMaxAnswers = 2;
			short pollMinAnswers = 1;
			var pollQuestion = generator.Generate<string>();
			var pollStartDate = generator.Generate<DateTime>();
			var pollEndDate = pollStartDate.AddDays(2);
			var userId = generator.Generate<int>();

			var polls = new InMemoryDbSet<MVPoll>();
			var pollOptions = new InMemoryDbSet<MVPollOption>();

			var entities = new Mock<IEntities>(MockBehavior.Strict);
			entities.Setup(_ => _.MVPolls).Returns(polls);
			entities.Setup(_ => _.MVPollOptions).Returns(pollOptions);
			entities.Setup(_ => _.SaveChanges()).Callback(() => polls.Local[0].PollID = pollId)
				.Returns(1);
			entities.Setup(_ => _.Dispose());

			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => entities.Object);

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var poll = new DataPortal<Poll>().Create(userId);
				poll.PollAdminRemovedFlag = pollAdminRemoveFlag;
				poll.PollCategoryID = pollCategoryId;
				poll.PollDateRemoved = pollDateRemoved;
				poll.PollDeletedDate = pollDeletedDate;
				poll.PollDeletedFlag = pollDeletedFlag;
				poll.PollDescription = pollDescription;
				poll.PollEndDate = pollEndDate;
				poll.PollImageLink = pollImageLink;
				poll.PollMaxAnswers = pollMaxAnswers;
				poll.PollMinAnswers = pollMinAnswers;
				poll.PollQuestion = pollQuestion;
				poll.PollStartDate = pollStartDate;
				poll.PollOptions.Add(PollLifecycleTests.CreatePollOption());
				poll.PollOptions.Add(PollLifecycleTests.CreatePollOption());

				poll = poll.Save();

				Assert.AreEqual(pollAdminRemoveFlag, poll.PollAdminRemovedFlag, poll.GetPropertyName(_ => _.PollAdminRemovedFlag));
				Assert.AreEqual(pollCategoryId, poll.PollCategoryID, poll.GetPropertyName(_ => _.PollCategoryID));
				Assert.AreEqual(pollDateRemoved, poll.PollDateRemoved, poll.GetPropertyName(_ => _.PollDateRemoved));
				Assert.AreEqual(pollDeletedDate, poll.PollDeletedDate, poll.GetPropertyName(_ => _.PollDeletedDate));
				Assert.AreEqual(pollDeletedFlag, poll.PollDeletedFlag, poll.GetPropertyName(_ => _.PollDeletedFlag));
				Assert.AreEqual(pollDescription, poll.PollDescription, poll.GetPropertyName(_ => _.PollDescription));
				Assert.AreEqual(pollEndDate.ToUniversalTime(), poll.PollEndDate, poll.GetPropertyName(_ => _.PollEndDate));
				Assert.AreEqual(pollId, poll.PollID, poll.GetPropertyName(_ => _.PollID));
				Assert.AreEqual(pollImageLink, poll.PollImageLink, poll.GetPropertyName(_ => _.PollImageLink));
				Assert.AreEqual(pollMaxAnswers, poll.PollMaxAnswers, poll.GetPropertyName(_ => _.PollMaxAnswers));
				Assert.AreEqual(pollMinAnswers, poll.PollMinAnswers, poll.GetPropertyName(_ => _.PollMinAnswers));
				Assert.AreEqual(pollQuestion, poll.PollQuestion, poll.GetPropertyName(_ => _.PollQuestion));
				Assert.AreEqual(pollStartDate.ToUniversalTime(), poll.PollStartDate, poll.GetPropertyName(_ => _.PollStartDate));
				Assert.AreEqual(userId, poll.UserID, poll.GetPropertyName(_ => _.UserID));
			}

			entities.VerifyAll();
		}
Ejemplo n.º 43
0
 public static void NewProductEdit(EventHandler<DataPortalResult<ProductEdit>> callback)
 {
   var dp = new DataPortal<ProductEdit>(DataPortal.ProxyModes.LocalOnly);
   dp.CreateCompleted += callback;
   dp.BeginCreate();
 }
Ejemplo n.º 44
0
		public void Delete()
		{
			var generator = new RandomObjectGenerator();
			var userId = generator.Generate<int>();
			var now = DateTime.UtcNow;

			var entity = EntityCreator.Create<MVPoll>(_ =>
			{
				_.PollDeletedFlag = false;
				_.PollMinAnswers = 1;
				_.PollMaxAnswers = 2;
				_.PollStartDate = now;
				_.PollEndDate = now.AddDays(2);
				_.UserID = userId;
			});
			entity.MVPollOptions = new List<MVPollOption> 
			{ 
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>() 
			};

			var polls = new InMemoryDbSet<MVPoll> { entity };

			var entities = new Mock<IEntities>(MockBehavior.Strict);
			entities.Setup(_ => _.MVPolls).Returns(polls);
			entities.Setup(_ => _.SetState(It.IsAny<MVPoll>(), EntityState.Modified));
			entities.Setup(_ => _.SaveChanges()).Returns(1);
			entities.Setup(_ => _.Dispose());

			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => entities.Object);

			var identity = new Mock<IUserIdentity>(MockBehavior.Strict);
			identity.Setup(_ => _.UserID).Returns(userId);
			identity.Setup(_ => _.IsInRole(UserRoles.Admin)).Returns(false);

			var principal = new Mock<IPrincipal>(MockBehavior.Strict);
			principal.Setup(_ => _.Identity).Returns(identity.Object);

			using (principal.Object.Bind(() => ApplicationContext.User))
			{
				using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
				{
					var poll = new DataPortal<Poll>().Fetch(entity.PollID);
					poll.Delete();
					poll = poll.Save();

					Assert.AreEqual(2, polls.Local.Count);
					var deletedPoll = polls.Local[1];
					Assert.IsNotNull(deletedPoll.PollDeletedDate, deletedPoll.GetPropertyName(_ => _.PollDeletedDate));
					Assert.IsTrue(deletedPoll.PollDeletedFlag.Value, deletedPoll.GetPropertyName(_ => _.PollDeletedFlag));
				}
			}

			principal.VerifyAll();
			identity.VerifyAll();
			entities.VerifyAll();
		}
Ejemplo n.º 45
0
 public OperationResult ExecuteNonQueryByTransaction(string serviceName, string connectionName, SqlCommandObject[] sqlScripts)
 {
     try
     {
         DataPortal portal = new DataPortal();
         return portal.ExecuteNonQueryByTransaction(serviceName, connectionName, sqlScripts);
     }
     catch (Exception ex)
     {
         return new OperationResult() { Message = ex.Message };
     }
 }
Ejemplo n.º 46
0
		public void Fetch()
		{
			var entity = EntityCreator.Create<MVPoll>(_ => _.PollDeletedFlag = false);
			entity.MVPollOptions = new List<MVPollOption> { EntityCreator.Create<MVPollOption>() };

			var entities = new Mock<IEntities>(MockBehavior.Strict);
			entities.Setup(_ => _.MVPolls).Returns(new InMemoryDbSet<MVPoll> { entity });
			entities.Setup(_ => _.Dispose());

			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => entities.Object);

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var poll = new DataPortal<Poll>().Fetch(entity.PollID);

				Assert.AreEqual(entity.PollAdminRemovedFlag, poll.PollAdminRemovedFlag, poll.GetPropertyName(_ => _.PollAdminRemovedFlag));
				Assert.AreEqual(entity.PollCategoryID, poll.PollCategoryID, poll.GetPropertyName(_ => _.PollCategoryID));
				Assert.AreEqual(entity.PollDateRemoved, poll.PollDateRemoved, poll.GetPropertyName(_ => _.PollDateRemoved));
				Assert.AreEqual(entity.PollDeletedDate, poll.PollDeletedDate, poll.GetPropertyName(_ => _.PollDeletedDate));
				Assert.AreEqual(entity.PollDeletedFlag, poll.PollDeletedFlag, poll.GetPropertyName(_ => _.PollDeletedFlag));
				Assert.AreEqual(entity.PollDescription, poll.PollDescription, poll.GetPropertyName(_ => _.PollDescription));
				Assert.AreEqual(entity.PollEndDate, poll.PollEndDate, poll.GetPropertyName(_ => _.PollEndDate));
				Assert.AreEqual(entity.PollID, poll.PollID, poll.GetPropertyName(_ => _.PollID));
				Assert.AreEqual(entity.PollImageLink, poll.PollImageLink, poll.GetPropertyName(_ => _.PollImageLink));
				Assert.AreEqual(entity.PollMaxAnswers, poll.PollMaxAnswers, poll.GetPropertyName(_ => _.PollMaxAnswers));
				Assert.AreEqual(entity.PollMinAnswers, poll.PollMinAnswers, poll.GetPropertyName(_ => _.PollMinAnswers));
				Assert.AreEqual(entity.PollQuestion, poll.PollQuestion, poll.GetPropertyName(_ => _.PollQuestion));
				Assert.AreEqual(entity.PollStartDate, poll.PollStartDate, poll.GetPropertyName(_ => _.PollStartDate));
				Assert.AreEqual(entity.UserID, poll.UserID, poll.GetPropertyName(_ => _.UserID));
				Assert.AreEqual(1, poll.PollOptions.Count, poll.GetPropertyName(_ => _.PollOptions));
			}

			entities.VerifyAll();
		}
Ejemplo n.º 47
0
 public OperationResult ExecuteDatasetByTransaction(string serviceName, string connectionName, string commandText, params object[] parameterValues)
 {
     try
     {
         DataPortal portal = new DataPortal();
         return portal.ExecuteDatasetByTransaction(serviceName, connectionName, commandText, parameterValues);
     }
     catch (Exception ex)
     {
         return new OperationResult() { Message = ex.Message };
     }
 }
Ejemplo n.º 48
0
 /// <summary>
 /// Factory method. Creates a new <see cref="F08_Region"/> object.
 /// </summary>
 /// <returns>A reference to the created <see cref="F08_Region"/> object.</returns>
 internal static F08_Region NewF08_Region()
 {
     return(DataPortal.CreateChild <F08_Region>());
 }
Ejemplo n.º 49
0
 /// <summary>
 /// Update a business object.
 /// </summary>
 /// <param name="obj">Business object to update.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 public DataPortalResult Update(object obj, DataPortalContext context)
 {
     Server.DataPortal portal = new DataPortal();
       return portal.Update(obj, context, true).Result;
 }
Ejemplo n.º 50
0
 /// <summary>
 /// Factory method. Creates a new <see cref="DocClass"/> object.
 /// </summary>
 /// <returns>A reference to the created <see cref="DocClass"/> object.</returns>
 public static DocClass NewDocClass()
 {
     return(DataPortal.Create <DocClass>());
 }
Ejemplo n.º 51
0
		public void Update()
		{
			var now = DateTime.UtcNow;

			var entity = EntityCreator.Create<MVPoll>(_ =>
			{
				_.PollDeletedFlag = false;
				_.PollMinAnswers = 1;
				_.PollMaxAnswers = 2;
				_.PollStartDate = now;
				_.PollEndDate = now.AddDays(2);
			});
			entity.MVPollOptions = new List<MVPollOption> 
			{ 
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>(),
				EntityCreator.Create<MVPollOption>() 
			};

			var generator = new RandomObjectGenerator();
			var newPollAdminRemoveFlag = generator.Generate<bool>();
			var newPollCategoryId = generator.Generate<int>();
			var newPollDateRemoved = generator.Generate<DateTime>();
			var newPollDeletedDate = generator.Generate<DateTime>();
			var newPollDeletedFlag = generator.Generate<bool>();
			var newPollDescription = generator.Generate<string>();
			var newPollEndDate = entity.PollEndDate.AddDays(1);
			var newPollImageLink = generator.Generate<string>();
			short newPollMaxAnswers = 3;
			short newPollMinAnswers = 2;
			var newPollQuestion = generator.Generate<string>();
			var newPollStartDate = entity.PollStartDate.AddDays(1);

			var entities = new Mock<IEntities>(MockBehavior.Strict);
			entities.Setup(_ => _.MVPolls).Returns(new InMemoryDbSet<MVPoll> { entity });
			entities.Setup(_ => _.SetState(It.IsAny<MVPoll>(), EntityState.Modified));
			entities.Setup(_ => _.SaveChanges()).Returns(1);
			entities.Setup(_ => _.Dispose());

			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => entities.Object);

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var poll = new DataPortal<Poll>().Fetch(entity.PollID);
				poll.PollAdminRemovedFlag = newPollAdminRemoveFlag;
				poll.PollCategoryID = newPollCategoryId;
				poll.PollDateRemoved = newPollDateRemoved;
				poll.PollDeletedDate = newPollDeletedDate;
				poll.PollDeletedFlag = newPollDeletedFlag;
				poll.PollDescription = newPollDescription;
				poll.PollEndDate = newPollEndDate;
				poll.PollImageLink = newPollImageLink;
				poll.PollMaxAnswers = newPollMaxAnswers;
				poll.PollMinAnswers = newPollMinAnswers;
				poll.PollQuestion = newPollQuestion;
				poll.PollStartDate = newPollStartDate;

				poll = poll.Save();

				Assert.AreEqual(newPollAdminRemoveFlag, poll.PollAdminRemovedFlag, poll.GetPropertyName(_ => _.PollAdminRemovedFlag));
				Assert.AreEqual(newPollCategoryId, poll.PollCategoryID, poll.GetPropertyName(_ => _.PollCategoryID));
				Assert.AreEqual(newPollDateRemoved, poll.PollDateRemoved, poll.GetPropertyName(_ => _.PollDateRemoved));
				Assert.AreEqual(newPollDeletedDate, poll.PollDeletedDate, poll.GetPropertyName(_ => _.PollDeletedDate));
				Assert.AreEqual(newPollDeletedFlag, poll.PollDeletedFlag, poll.GetPropertyName(_ => _.PollDeletedFlag));
				Assert.AreEqual(newPollDescription, poll.PollDescription, poll.GetPropertyName(_ => _.PollDescription));
				Assert.AreEqual(newPollEndDate.ToUniversalTime(), poll.PollEndDate, poll.GetPropertyName(_ => _.PollEndDate));
				Assert.AreEqual(newPollImageLink, poll.PollImageLink, poll.GetPropertyName(_ => _.PollImageLink));
				Assert.AreEqual(newPollMaxAnswers, poll.PollMaxAnswers, poll.GetPropertyName(_ => _.PollMaxAnswers));
				Assert.AreEqual(newPollMinAnswers, poll.PollMinAnswers, poll.GetPropertyName(_ => _.PollMinAnswers));
				Assert.AreEqual(newPollQuestion, poll.PollQuestion, poll.GetPropertyName(_ => _.PollQuestion));
				Assert.AreEqual(newPollStartDate.ToUniversalTime(), poll.PollStartDate, poll.GetPropertyName(_ => _.PollStartDate));
			}

			entities.VerifyAll();
		}
Ejemplo n.º 52
0
 /// <summary>
 /// Factory method. Loads a <see cref="DocClass"/> object, based on given parameters.
 /// </summary>
 /// <param name="docClassID">The DocClassID parameter of the DocClass to fetch.</param>
 /// <returns>A reference to the fetched <see cref="DocClass"/> object.</returns>
 public static DocClass GetDocClass(int docClassID)
 {
     return(DataPortal.Fetch <DocClass>(docClassID));
 }
Ejemplo n.º 53
0
 /// <summary>
 /// Factory method. Deletes a <see cref="DocClass"/> object, based on given parameters.
 /// </summary>
 /// <param name="docClassID">The DocClassID of the DocClass to delete.</param>
 public static void DeleteDocClass(int docClassID)
 {
     DataPortal.Delete <DocClass>(docClassID);
 }
Ejemplo n.º 54
0
 /// <summary>
 /// Factory method. Asynchronously creates a new <see cref="DocClass"/> object.
 /// </summary>
 /// <param name="callback">The completion callback method.</param>
 public static void NewDocClass(EventHandler <DataPortalResult <DocClass> > callback)
 {
     DataPortal.BeginCreate <DocClass>(callback);
 }
Ejemplo n.º 55
0
    public void Delete_PrimitiveCriteria()
    {
      var context = GetContext();
      object userState = "state";
      DataPortal<PrimitiveCriteriaSingle> dp = new DataPortal<PrimitiveCriteriaSingle>();
      dp.DeleteCompleted +=
        (o1, e1) =>
        {
          context.Assert.IsNull(e1.Error);

          context.Assert.AreEqual(dp.GlobalContext["PrimitiveCriteriaSingle"].ToString(), "Deleted");
          context.Assert.Success();
        };
      dp.BeginDelete(5);
      context.Complete();
    }
Ejemplo n.º 56
0
 public static MyRoot GetRoot(int id)
 {
     return(DataPortal.Fetch <MyRoot>(id));
 }