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