public int Update(Spartane.Core.Classes.Spartan_Format.Spartan_Format entity)
        {
            int rta;

            try
            {
                var paramUpdFormatId = _dataProvider.GetParameter();
                paramUpdFormatId.ParameterName = "FormatId";
                paramUpdFormatId.DbType        = DbType.Int32;
                paramUpdFormatId.Value         = (object)entity.FormatId ?? DBNull.Value;
                var paramUpdRegistration_Date = _dataProvider.GetParameter();
                paramUpdRegistration_Date.ParameterName = "Registration_Date";
                paramUpdRegistration_Date.DbType        = DbType.DateTime;
                paramUpdRegistration_Date.Value         = (object)entity.Registration_Date ?? DBNull.Value;

                var paramUpdRegistration_Hour = _dataProvider.GetParameter();
                paramUpdRegistration_Hour.ParameterName = "Registration_Hour";
                paramUpdRegistration_Hour.DbType        = DbType.String;
                paramUpdRegistration_Hour.Value         = (object)entity.Registration_Hour ?? DBNull.Value;
                var paramUpdRegistration_User = _dataProvider.GetParameter();
                paramUpdRegistration_User.ParameterName = "Registration_User";
                paramUpdRegistration_User.DbType        = DbType.Int32;
                paramUpdRegistration_User.Value         = (object)entity.Registration_User ?? DBNull.Value;

                var paramUpdFormat_Name = _dataProvider.GetParameter();
                paramUpdFormat_Name.ParameterName = "Format_Name";
                paramUpdFormat_Name.DbType        = DbType.String;
                paramUpdFormat_Name.Value         = (object)entity.Format_Name ?? DBNull.Value;
                var paramUpdFormat_Type = _dataProvider.GetParameter();
                paramUpdFormat_Type.ParameterName = "Format_Type";
                paramUpdFormat_Type.DbType        = DbType.Int16;
                paramUpdFormat_Type.Value         = (object)entity.Format_Type ?? DBNull.Value;

                var paramUpdSearch = _dataProvider.GetParameter();
                paramUpdSearch.ParameterName = "Search";
                paramUpdSearch.DbType        = DbType.String;
                paramUpdSearch.Value         = (object)entity.Search ?? DBNull.Value;
                var paramUpdObject = _dataProvider.GetParameter();
                paramUpdObject.ParameterName = "Object";
                paramUpdObject.DbType        = DbType.Int32;
                paramUpdObject.Value         = (object)entity.Object ?? DBNull.Value;

                var paramUpdHeader = _dataProvider.GetParameter();
                paramUpdHeader.ParameterName = "Header";
                paramUpdHeader.DbType        = DbType.String;
                paramUpdHeader.Value         = (object)entity.Header ?? DBNull.Value;
                var paramUpdBody = _dataProvider.GetParameter();
                paramUpdBody.ParameterName = "Body";
                paramUpdBody.DbType        = DbType.String;
                paramUpdBody.Value         = (object)entity.Body ?? DBNull.Value;
                var paramUpdFooter = _dataProvider.GetParameter();
                paramUpdFooter.ParameterName = "Footer";
                paramUpdFooter.DbType        = DbType.String;
                paramUpdFooter.Value         = (object)entity.Footer ?? DBNull.Value;

                var paramUpdFilter = _dataProvider.GetParameter();
                paramUpdFilter.ParameterName = "Filter";
                paramUpdFilter.DbType        = DbType.String;
                paramUpdFilter.Value         = (object)entity.Filter ?? DBNull.Value;


                var empEntity =
                    _dbContext.ExecuteStoredProcedureList <Spartane.Core.Classes.StoredProcedure.sp_UpdSpartan_Format>("sp_UpdSpartan_Format", paramUpdFormatId, paramUpdRegistration_Date, paramUpdRegistration_Hour, paramUpdRegistration_User, paramUpdFormat_Name, paramUpdFormat_Type, paramUpdSearch, paramUpdObject, paramUpdHeader, paramUpdBody, paramUpdFooter, paramUpdFilter).FirstOrDefault();

                rta = Convert.ToInt32(empEntity.FormatId);

                var listFormatField = _ISpartan_Format_FieldService.SelAll(false, "Format=" + rta, string.Empty);

                //Borro todos los fields
                foreach (var field in listFormatField)
                {
                    _ISpartan_Format_FieldService.Delete(field.FormatFieldId);
                }
                //Los inserto nuevamente
                foreach (var field in entity.Format_Field_Spartan_Format_Field)
                {
                    field.Format = rta;
                    _ISpartan_Format_FieldService.Insert(field);
                }
            }
            catch (ExceptionBase ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new ServiceException(ex.Message, ex);
            }

            return(rta);
        }
        public int Insert(Spartane.Core.Classes.Spartan_Format.Spartan_Format entity)
        {
            int rta;

            try
            {
                var padreRegistration_Date = _dataProvider.GetParameter();
                padreRegistration_Date.ParameterName = "Registration_Date";
                padreRegistration_Date.DbType        = DbType.DateTime;
                padreRegistration_Date.Value         = (object)entity.Registration_Date ?? DBNull.Value;

                var padreRegistration_Hour = _dataProvider.GetParameter();
                padreRegistration_Hour.ParameterName = "Registration_Hour";
                padreRegistration_Hour.DbType        = DbType.String;
                padreRegistration_Hour.Value         = (object)entity.Registration_Hour ?? DBNull.Value;
                var padreRegistration_User = _dataProvider.GetParameter();
                padreRegistration_User.ParameterName = "Registration_User";
                padreRegistration_User.DbType        = DbType.Int32;
                padreRegistration_User.Value         = (object)entity.Registration_User ?? DBNull.Value;

                var padreFormat_Name = _dataProvider.GetParameter();
                padreFormat_Name.ParameterName = "Format_Name";
                padreFormat_Name.DbType        = DbType.String;
                padreFormat_Name.Value         = (object)entity.Format_Name ?? DBNull.Value;
                var padreFormat_Type = _dataProvider.GetParameter();
                padreFormat_Type.ParameterName = "Format_Type";
                padreFormat_Type.DbType        = DbType.Int16;
                padreFormat_Type.Value         = (object)entity.Format_Type ?? DBNull.Value;

                var padreSearch = _dataProvider.GetParameter();
                padreSearch.ParameterName = "Search";
                padreSearch.DbType        = DbType.String;
                padreSearch.Value         = (object)entity.Search ?? DBNull.Value;
                var padreObject = _dataProvider.GetParameter();
                padreObject.ParameterName = "Object";
                padreObject.DbType        = DbType.Int32;
                padreObject.Value         = (object)entity.Object ?? DBNull.Value;

                var padreHeader = _dataProvider.GetParameter();
                padreHeader.ParameterName = "Header";
                padreHeader.DbType        = DbType.String;
                padreHeader.Value         = (object)entity.Header ?? DBNull.Value;
                var padreBody = _dataProvider.GetParameter();
                padreBody.ParameterName = "Body";
                padreBody.DbType        = DbType.String;
                padreBody.Value         = (object)entity.Body ?? DBNull.Value;
                var padreFooter = _dataProvider.GetParameter();
                padreFooter.ParameterName = "Footer";
                padreFooter.DbType        = DbType.String;
                padreFooter.Value         = (object)entity.Footer ?? DBNull.Value;

                var padreFilter = _dataProvider.GetParameter();
                padreFilter.ParameterName = "Filter";
                padreFilter.DbType        = DbType.String;
                padreFilter.Value         = (object)entity.Filter ?? DBNull.Value;

                var empEntity =
                    _dbContext.ExecuteStoredProcedureList <Spartane.Core.Classes.StoredProcedure.sp_InsSpartan_Format>("sp_InsSpartan_Format", padreRegistration_Date
                                                                                                                       , padreRegistration_Hour
                                                                                                                       , padreRegistration_User
                                                                                                                       , padreFormat_Name
                                                                                                                       , padreFormat_Type
                                                                                                                       , padreSearch
                                                                                                                       , padreObject
                                                                                                                       , padreHeader
                                                                                                                       , padreBody
                                                                                                                       , padreFooter
                                                                                                                       , padreFilter
                                                                                                                       ).FirstOrDefault();

                rta = Convert.ToInt32(empEntity.FormatId);

                foreach (var field in entity.Format_Field_Spartan_Format_Field)
                {
                    field.Format = rta;
                    _ISpartan_Format_FieldService.Insert(field);
                }
            }
            catch (ExceptionBase ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new ServiceException(ex.Message, ex);
            }

            return(rta);
        }