public ActionResult HandleChanges(StoreDataHandler handler)
        {
            ChangeRecords <TestPerson> persons = handler.BatchObjectData <TestPerson>();
            var store = this.GetCmp <Store>("Store1");

            foreach (TestPerson created in persons.Created)
            {
                TestPerson.AddPerson(created);

                var record = store.GetByInternalId(created.PhantomId);
                record.CreateVariable = true;
                record.SetId(created.Id);
                record.Commit();
                created.PhantomId = null;
            }

            foreach (TestPerson deleted in persons.Deleted)
            {
                TestPerson.DeletePerson(deleted.Id.Value);
                store.CommitRemoving(deleted.Id.Value);
            }

            foreach (TestPerson updated in persons.Updated)
            {
                TestPerson.UpdatePerson(updated);

                var record = store.GetById(updated.Id.Value);
                record.Commit();
            }

            return(this.Direct());
        }
        public ActionResult HandleChanges(StoreDataHandler handler)
        {
            List <TestPerson> persons = handler.ObjectData <TestPerson>();

            if (handler.Action == StoreAction.Create)
            {
                foreach (TestPerson created in persons)
                {
                    TestPerson.AddPerson(created);
                }
            }
            else if (handler.Action == StoreAction.Destroy)
            {
                foreach (TestPerson deleted in persons)
                {
                    TestPerson.DeletePerson(deleted.Id.Value);
                }
            }
            else if (handler.Action == StoreAction.Update)
            {
                foreach (TestPerson updated in persons)
                {
                    TestPerson.UpdatePerson(updated);
                }
            }

            return(handler.Action != StoreAction.Destroy ? (ActionResult)this.Store(persons) : (ActionResult)this.Content(""));
        }
        public ActionResult HandleChanges(StoreDataHandler handler)
        {
            List <TestPerson> persons      = handler.ObjectData <TestPerson>();
            string            errorMessage = null;

            if (handler.Action == StoreAction.Create)
            {
                foreach (TestPerson created in persons)
                {
                    TestPerson.AddPerson(created);
                }
            }
            else if (handler.Action == StoreAction.Destroy)
            {
                foreach (TestPerson deleted in persons)
                {
                    TestPerson.DeletePerson(deleted.Id.Value);
                }
            }
            else if (handler.Action == StoreAction.Update)
            {
                foreach (TestPerson updated in persons)
                {
                    try
                    {
                        TestPerson.UpdatePerson(updated);
                    }
                    catch (Exception e)
                    {
                        errorMessage = e.Message;
                    }
                }
            }

            if (errorMessage != null)
            {
                return(this.Store(errorMessage));
            }

            return(handler.Action != StoreAction.Destroy ? (ActionResult)this.Store(persons) : (ActionResult)this.Content(""));
        }
        public RestResult Create(TestPerson person)
        {
            try
            {
                TestPerson.AddPerson(person);

                return(new RestResult
                {
                    Success = true,
                    Message = "New person is added",
                    Data = person
                });
            }
            catch (Exception e)
            {
                return(new RestResult
                {
                    Success = false,
                    Message = e.Message
                });
            }
        }