public virtual ActionResult Update(DispatchListsTable dispatchLists)
        {
            int resultado = 0;

            try
            {
                int dispatchID = DispatchLists.UPDDispatchLists(dispatchLists.Name, dispatchLists.DispatchListID);
                int RowCount   = DispatchLists.DelDispatchLists(dispatchID);

                foreach (var account in dispatchLists.Accounts)
                {
                    DispatchsItemsParameters objE = new DispatchsItemsParameters();
                    objE.AccountNumber  = Convert.ToString(account.AccountID);
                    objE.DispatchListID = dispatchID;

                    resultado = DispatchItemsList.InsertDispatchListItems(objE);
                }
            }
            catch (Exception ex)
            {
                var exception = EntityExceptionHelper.GetAndLogNetStepsException(ex, NetSteps.Data.Entities.Constants.NetStepsExceptionType.NetStepsApplicationException);
                throw exception;
            }
            return(Json(new { result = (resultado == 0 ? false : true) }));
        }
        public virtual ActionResult Save(DispatchListsTable dispatchLists)
        {
            int resultado = 0;

            try
            {
                if (dispatchLists.DispatchListID > 0)
                {
                    resultado = DispatchLists.UpdateDispatch(dispatchLists);
                }
                else
                {
                    using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required))
                    {
                        int dispatchListID = DispatchLists.InsertDispatch(dispatchLists);
                        if (dispatchListID < 1)
                        {
                            tran.Dispose();
                            return(Json(new { result = false, message = "No se grabó correctamente en la tabla Dispatch List" }));
                        }
                        foreach (var account in dispatchLists.Accounts)
                        {
                            DispatchsItemsParameters objE = new DispatchsItemsParameters();
                            objE.AccountNumber  = Convert.ToString(account.AccountID);
                            objE.DispatchListID = dispatchListID;

                            if (DispatchItemsList.InsertDispatchListItems(objE) < 1)
                            {
                                tran.Dispose();
                                return(Json(new { result = false, message = "No se grabó correctamente en la tabla Dispatch List" }));
                            }
                        }
                        resultado = 1;
                        tran.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                var exception = EntityExceptionHelper.GetAndLogNetStepsException(ex, NetSteps.Data.Entities.Constants.NetStepsExceptionType.NetStepsApplicationException);
                throw exception;
            }
            return(Json(new { result = (resultado == 0 ? false : true) }));
        }