protected GenieLamp.Examples.QuickStart.Services.Interfaces.CommitResult PersistenceAction(GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO.Action action, bool throwException)
        {
            GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO uow = new GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO();
            foreach (T item in this)
            {
                switch (action)
                {
                case GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO.Action.Save:
                    uow.Save(item.DTO);
                    break;

                case GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO.Action.Delete:
                    uow.Delete(item.DTO);
                    break;
                }
            }
            GenieLamp.Examples.QuickStart.Services.Interfaces.PersistenceRequest request = new GenieLamp.Examples.QuickStart.Services.Interfaces.PersistenceRequest();
            request.UnitOfWork = uow;
            GenieLamp.Examples.QuickStart.Services.Interfaces.PersistenceResponse responce = WebClientFactory.GetJsonClient().Post <GenieLamp.Examples.QuickStart.Services.Interfaces.PersistenceResponse>("/Persistence", request);
            if (throwException && responce.CommitResult.HasError)
            {
                throw new GenieLamp.Examples.QuickStart.Services.Interfaces.CommitException(responce.CommitResult);
            }
            if (!responce.CommitResult.HasError)
            {
                if (action == GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO.Action.Delete)
                {
                    this.Clear();
                }
                else
                {
                    foreach (T item in this)
                    {
                        TDTO dto = item.DTO as TDTO;
                        responce.UpdatedObjects.Update <TDTO>(ref dto);
                        item.DTO = dto;
                    }
                    ResetChanged();
                }
            }
            return(responce.CommitResult);
        }
        protected GenieLamp.Examples.QuickStart.Services.Interfaces.CommitResult PersistenceAction <T>(GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO.Action action, bool throwException) where T : GenieLamp.Examples.QuickStart.Services.Interfaces.DomainObjectDTO
        {
            GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO uow = new GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO();
            switch (action)
            {
            case GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO.Action.Save:
                uow.Save(this.dto as GenieLamp.Examples.QuickStart.Services.Interfaces.PersistentObjectDTO);
                break;

            case GenieLamp.Examples.QuickStart.Services.Interfaces.UnitOfWorkDTO.Action.Delete:
                uow.Delete(this.dto as GenieLamp.Examples.QuickStart.Services.Interfaces.PersistentObjectDTO);
                break;
            }
            GenieLamp.Examples.QuickStart.Services.Interfaces.PersistenceRequest request = new GenieLamp.Examples.QuickStart.Services.Interfaces.PersistenceRequest();
            request.UnitOfWork = uow;
            GenieLamp.Examples.QuickStart.Services.Interfaces.PersistenceResponse responce = WebClientFactory.GetJsonClient().Post <GenieLamp.Examples.QuickStart.Services.Interfaces.PersistenceResponse>("/Persistence", request);
            if (throwException && responce.CommitResult.HasError)
            {
                throw new GenieLamp.Examples.QuickStart.Services.Interfaces.CommitException(responce.CommitResult);
            }
            if (!responce.CommitResult.HasError)
            {
                T dto = this.dto as T;
                responce.UpdatedObjects.Update <T>(ref dto);
                this.dto = dto;
            }
            return(responce.CommitResult);
        }