/// <summary>
        /// Processes the submit.
        /// </summary>
        /// <param name="changeSet">The change set.</param>
        /// <returns>Returns True if successful, otherwise false.</returns>
        protected override bool ProcessSubmit(ChangeSet changeSet)
        {
            bool success = true;

            try
            {
                foreach (ChangeSetEntry entry in changeSet.ChangeSetEntries)
                {
                    switch (entry.Operation)
                    {
                        case ChangeOperation.Update:
                            DbEntityEntry deliveryEntry = _dbContext.Entry(entry.Entity);

                            Customer customer = _dbContext.Customers.Local.FirstOrDefault(c => c.CustomerId == (deliveryEntry.Entity as Delivery).CustomerId);
                            if (customer != null)
                            {
                                (deliveryEntry.Entity as Delivery).Customer = customer;
                            }

                            deliveryEntry.State = EntityState.Modified;
                            _dbContext.SaveChanges();
                            break;
                    }
                }

            }
            catch (Exception ex)
            {
                success = false;
            }

            return success;
        }
Ejemplo n.º 2
0
        public virtual bool Submit(IEnumerable<ChangeSetEntry> changeSet)
        {
            if (changeSet == null)
            {
                throw new ArgumentNullException("changeSetEntries");
            }

            _changeSet = new ChangeSet(changeSet, _description.EntityTypes);

            return ProcessSubmit(_changeSet);
        }
Ejemplo n.º 3
0
 protected abstract bool ProcessSubmit(ChangeSet changeSet);