Example #1
0
        protected override void PerformActionProcess(Controller controller)
        {
            ARDataBinder binder = new ARDataBinder();

            object instance = binder.BindObject(Model.Type, "", controller.Params);

            SessionScope scope = new SessionScope();

            try
            {
                CommonOperationUtils.SaveInstance(instance, controller, errors, prop2Validation);

                scope.Dispose();

                controller.Redirect(controller.AreaName, controller.Name, "list" + Model.Type.Name);
            }
            catch (Exception ex)
            {
                errors.Add("Could not save " + Model.Type.Name + ". " + ex.Message);

                scope.Dispose(true);
            }

            if (errors.Count != 0)
            {
                controller.Context.Flash["errors"] = errors;
                controller.Redirect(controller.AreaName, controller.Name, "new" + Model.Type.Name);
            }
        }
Example #2
0
		public void CanBindPrimaryKeyToEmptyGuid()
		{
			Tag tag = new Tag() { Id = Guid.Empty, Name = "TopMovie" };
			tag.Create();

			var request = new StubRequest();
			request.Params["tag.id"] = Guid.Empty.ToString();

			var binder = new ARDataBinder { AutoLoad = AutoLoadBehavior.Always, TreatEmptyGuidAsNull = false};
			
			var record = (Tag)binder.BindObject(typeof(Tag), "tag", request.ParamsNode);
	
			Assert.AreEqual(tag.Id, record.Id);
		}
Example #3
0
        public void CanBindPrimaryKeyToEmptyGuid()
        {
            var tag = new Tag
            {
                Id   = Guid.Empty,
                Name = "TopMovie"
            };

            tag.Create();

            var request = new StubRequest();

            request.Params["tag.id"] = Guid.Empty.ToString();

            var binder = new ARDataBinder {
                AutoLoad = AutoLoadBehavior.Always, TreatEmptyGuidAsNull = false
            };

            var record = (Tag)binder.BindObject(typeof(Tag), "tag", request.ParamsNode);

            Assert.AreEqual(tag.Id, record.Id);
        }
        public void AutoloadOnSuccessScenario()
        {
            String data = @"
				SimplePerson@autoload = yes
				SimplePerson.Id = 15
				SimplePerson.Age = 200
			"            ;

            args = DataBinderTestCase.ParseNameValueString(data);

            instance = binder.BindObject(typeof(SimplePerson), "SimplePerson", args);

            Assert.IsNotNull(instance);
            person = instance as SimplePerson;
            // since we are doing auto load the name property should
            // had being populated already
            Assert.IsTrue(person.Name == "Name 15", "AutoLoad failed to load db property");
            //  (Age should had being overwritten)
            Assert.IsTrue(person.Age == 200, "AutoLoad Failed to overwrite db property");
        }