public static int Create(ContinentDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Create", requestProfile); var newId = DBDML.RunScalarSQL("Continent.Insert", sql, DataStoreKey); return(Convert.ToInt32(newId)); }
public void Delete(string value) { var dataQuery = new ContinentDataModel(); dataQuery.ContinentId = int.Parse(value); ContinentDataManager.Delete(dataQuery, SessionVariables.RequestProfile); }
public static string Save(ContinentDataModel data, string action, RequestProfile requestProfile) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.ContinentInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.ContinentUpdate " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, ContinentDataModel.DataColumns.ContinentId); sql = sql + ", " + ToSQLParameter(data, ContinentDataModel.DataColumns.Name); sql = sql + ", " + ToSQLParameter(data, ContinentDataModel.DataColumns.Description); sql = sql + ", " + ToSQLParameter(data, ContinentDataModel.DataColumns.SortOrder); return(sql); }
public static string ToSQLParameter(ContinentDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case ContinentDataModel.DataColumns.ContinentId: if (data.ContinentId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, ContinentDataModel.DataColumns.ContinentId, data.ContinentId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ContinentDataModel.DataColumns.ContinentId); } break; case ContinentDataModel.DataColumns.Name: if (!string.IsNullOrEmpty(data.Name)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, ContinentDataModel.DataColumns.Name, data.Name); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ContinentDataModel.DataColumns.Name); } break; case ContinentDataModel.DataColumns.Description: if (!string.IsNullOrEmpty(data.Description)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, ContinentDataModel.DataColumns.Description, data.Description); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ContinentDataModel.DataColumns.Description); } break; case ContinentDataModel.DataColumns.SortOrder: if (data.SortOrder != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, ContinentDataModel.DataColumns.SortOrder, data.SortOrder); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ContinentDataModel.DataColumns.SortOrder); } break; default: returnValue = BaseDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
public ContinentDataModel GetById(string value) { var dataQuery = new ContinentDataModel(); dataQuery.ContinentId = int.Parse(value); var result = ContinentDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile, 1); return(result[0]); }
public static bool DoesExist(ContinentDataModel data, RequestProfile requestProfile) { var doesExistRequest = new ContinentDataModel(); doesExistRequest.ApplicationId = data.ApplicationId; doesExistRequest.Name = data.Name; var list = GetEntityDetails(doesExistRequest, requestProfile, 0); return(list.Count > 0); }
public static void Delete(ContinentDataModel data, RequestProfile requestProfile) { const string sql = @"dbo.ContinentDelete "; var parameters = new { AuditId = requestProfile.AuditId , ContinentId = data.ContinentId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
public static List <ContinentDataModel> GetEntityDetails(ContinentDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails) { const string sql = @"dbo.ContinentSearch "; var parameters = new { AuditId = requestProfile.AuditId , ApplicationId = requestProfile.ApplicationId , ReturnAuditInfo = returnAuditInfo , ContinentId = dataQuery.ContinentId , Name = dataQuery.Name }; List <ContinentDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <ContinentDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
public void Update([FromBody] ContinentDataModel data) { ContinentDataManager.Update(data, SessionVariables.RequestProfile); }
public static void Update(ContinentDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Update", requestProfile); DBDML.RunSQL("Continent.Update", sql, DataStoreKey); }
public static DataTable Search(ContinentDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 0); return(list.ToDataTable()); }