Ejemplo n.º 1
0
        public static void ExecuteCommand(string parameter, EventHandler <DataPortalResult <TestCommandBase> > handler, object userState)
        {
            var dp = new DataPortal <TestCommandBase>();

            dp.ExecuteCompleted += handler;
            dp.BeginExecute(new TestCommandBase(parameter), userState);
        }
Ejemplo n.º 2
0
        private static void IsDuplicateName(AsyncValidationRuleContext context)
        {
            DuplicateCompanyCommand command         = new DuplicateCompanyCommand(context.PropertyValues["CompanyName"].ToString(), (int)context.PropertyValues["CompanyId"]);
            DataPortal <DuplicateCompanyCommand> dp = new DataPortal <DuplicateCompanyCommand>();

            dp.ExecuteCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    context.OutArgs.Description = String.Format("Error checking for duplicate company name.  {0}", e.Error);
                    context.OutArgs.Severity    = RuleSeverity.Error;
                    context.OutArgs.Result      = false;
                }
                else
                {
                    if (e.Object.IsDuplicate)
                    {
                        context.OutArgs.Description = "Duplicate company name.";
                        context.OutArgs.Severity    = RuleSeverity.Error;
                        context.OutArgs.Result      = false;
                    }
                    else
                    {
                        context.OutArgs.Result = true;
                    }
                }
                context.Complete();
            };
            dp.BeginExecute(command);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Async lookup of customer name
        /// </summary>
        /// <param name="customerId">
        /// The customer id.
        /// </param>
        /// <param name="callback">
        /// The callback function to execute when async call is completed.
        /// </param>
        public static void BeginExecute(int customerId, EventHandler <DataPortalResult <LookupCustomerCommand> > callback)
        {
            var cmd = new LookupCustomerCommand();

            cmd.CustomerId = customerId;
            DataPortal.BeginExecute <LookupCustomerCommand>(cmd, callback);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Async Exist of customer name
        /// </summary>
        /// <param name="customerName">
        /// The customer Name.
        /// </param>
        /// <param name="callback">
        /// The callback function to execute when async call is completed.
        /// </param>
        public static void BeginExecute(string name, EventHandler <DataPortalResult <NameCustomerCommand> > callback)
        {
            var cmd = new NameCustomerCommand();

            cmd.Name = name;
            DataPortal.BeginExecute <NameCustomerCommand>(cmd, callback);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Async Exist of customer name
        /// </summary>
        /// <param name="customerName">
        /// The customer Name.
        /// </param>
        /// <param name="callback">
        /// The callback function to execute when async call is completed.
        /// </param>
        public static void BeginExecute(string name, int id, EventHandler <DataPortalResult <DuplicateNameCommand> > callback)
        {
            var cmd = new DuplicateNameCommand();

            cmd.Name = name;
            cmd.Id   = id;
            DataPortal.BeginExecute <DuplicateNameCommand>(cmd, callback);
        }
Ejemplo n.º 6
0
        public static void CloseProject(int id, EventHandler <DataPortalResult <ProjectCloser> > callback)
        {
            ProjectCloser cmd = new ProjectCloser {
                ProjectId = id
            };

            DataPortal.BeginExecute <ProjectCloser>(cmd, callback);
        }
        public static void BeginExecuteCommand(EventHandler <DataPortalResult <AsyncPortalWithCulture> > handler)
        {
            var command = new AsyncPortalWithCulture();
            var dp      = new DataPortal <AsyncPortalWithCulture>();

            dp.ExecuteCompleted += handler;
            dp.BeginExecute(command);
        }
Ejemplo n.º 8
0
        public static void GetCompanyEdit(int companyID, EventHandler <DataPortalResult <CompanyEditUoW> > callback)
        {
#pragma warning disable 0618
            var command = new CompanyEditUoW();
            command.LoadProperty(CompanyIDProperty, companyID);
#pragma warning restore 0618

            DataPortal.BeginExecute <CompanyEditUoW>(command, callback);
        }
Ejemplo n.º 9
0
        public static void BeginExecute(int companyID, string companyName,
                                        EventHandler <DataPortalResult <DuplicateCompanyCommand> > callback)
        {
            var cmd = new DuplicateCompanyCommand();

            cmd.CompanyID   = companyID;
            cmd.CompanyName = companyName;

            DataPortal.BeginExecute <DuplicateCompanyCommand>(cmd, callback);
        }
Ejemplo n.º 10
0
 public static void Exists(int id, Action<bool> result)
 {
   var cmd = new ProjectExistsCommand(id);
   DataPortal.BeginExecute<ProjectExistsCommand>(cmd, (o, e) =>
   {
     if (e.Error != null)
       throw e.Error;
     else
       result(e.Object.ProjectExists);
   });
 }
Ejemplo n.º 11
0
        public static void Execute(string name, Action <bool> result)
        {
            var cmd = new NameRequiredCommand(name);

            DataPortal.BeginExecute(cmd, (o, e) =>
            {
                if (e.Error != null)
                {
                    throw e.Error;
                }
                else
                {
                    result(e.Object.Required);
                }
            });
        }
Ejemplo n.º 12
0
        public static void NameExistsForBusinessRules(string name, Action <bool> result)
        {
            var cmd = new CustomerNameCommand(name);

            DataPortal.BeginExecute <CustomerNameCommand>(cmd, (o, e) =>
            {
                if (e.Error != null)
                {
                    throw e.Error;
                }
                else
                {
                    result(e.Object.isExist);
                }
            });
        }
Ejemplo n.º 13
0
        public static void BeginCommand(Action <MyExpensiveCommand> callback)
        {
            var cmd = new MyExpensiveCommand();

            DataPortal.BeginExecute <MyExpensiveCommand>(cmd, (o, e) =>
            {
                if (e.Error != null)
                {
                    cmd.ResultText = e.Error.Message;
                    cmd.Result     = false;
                }
                else
                {
                    cmd = e.Object;
                }
                callback(cmd);
            });
        }
Ejemplo n.º 14
0
        public static void Execute(string address, Action <bool> result)
        {
            var cmd = new AddressExistsCommand(new Criteria()
            {
                Address = address
            });

            DataPortal.BeginExecute(cmd, (o, e) =>
            {
                if (e.Error != null)
                {
                    throw e.Error;
                }
                else
                {
                    result(e.Object.isExist);
                }
            });
        }
Ejemplo n.º 15
0
 public void BeginExecute(T command)
 {
     DataPortal.BeginExecute(command, ExecuteCompleted);
 }
Ejemplo n.º 16
0
 public void BeginExecute(T command, object userState)
 {
     DataPortal.BeginExecute(command, ExecuteCompleted, userState);
 }