private static string CreateOrUpdate(DevelopmentCategoryDataModel data, RequestProfile requestProfile, string action) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.DevelopmentCategoryInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.DevelopmentCategoryUpdate " + "\r\n" + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) + ", " + ToSQLParameter(data, DevelopmentCategoryDataModel.DataColumns.DevelopmentCategoryId) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder); return(sql); }
public ActionResult Index2(string searchString, int?page, int?pageSize) { var obj = new DevelopmentCategoryDataModel(); obj.Name = searchString; var list = DevelopmentCategoryDataManager.GetEntitySearch(obj, SessionVariables.RequestProfile); if (pageSize.HasValue) { SessionVariables.DefaultRowCount = pageSize.Value; } int pageNumber = (page - 1 ?? 0); ViewBag.searchString = searchString; ViewBag.CurrentPage = list.Count > 0 ? pageNumber + 1 : 0; ViewBag.TotalPages = list.Count / SessionVariables.DefaultRowCount; if (list.Count % SessionVariables.DefaultRowCount != 0) { ViewBag.TotalPages = (list.Count / SessionVariables.DefaultRowCount) + 1; } list = list.Count > 0 ? list.Skip(pageNumber * SessionVariables.DefaultRowCount).Take(SessionVariables.DefaultRowCount).ToList() : list; return(View(list)); }
public static int Create(DevelopmentCategoryDataModel data, RequestProfile requestProfile) { var sql = CreateOrUpdate(data, requestProfile, "Create"); var DevelopmentCategoryId = DBDML.RunScalarSQL("DevelopmentCategory.Insert", sql, DataStoreKey); return(Convert.ToInt32(DevelopmentCategoryId)); }
static public List <DevelopmentCategoryDataModel> GetEntitySearch(DevelopmentCategoryDataModel obj, RequestProfile requestProfile) { var dt = Search(obj, requestProfile); var list = ToList(dt); return(list); }
public static DataTable Search(DevelopmentCategoryDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile); var table = list.ToDataTable(); return(table); }
public static DataTable DoesExist(DevelopmentCategoryDataModel data, RequestProfile requestProfile) { var doesExistRequest = new DevelopmentCategoryDataModel(); doesExistRequest.Name = data.Name; return(Search(doesExistRequest, requestProfile)); }
public JsonResult IndexResult(string name, int?page, int?pageSize) { var obj = new DevelopmentCategoryDataModel(); obj.Name = name; var list = DevelopmentCategoryDataManager.GetEntitySearch(obj, SessionVariables.RequestProfile); return(Json(list, JsonRequestBehavior.AllowGet)); }
public static bool DoesExist(DevelopmentCategoryDataModel data, RequestProfile requestProfile) { var doesExistRequest = new DevelopmentCategoryDataModel(); doesExistRequest.Name = data.Name; var list = GetEntityDetails(doesExistRequest, requestProfile); return(list.Count > 0); }
public ActionResult Create(DevelopmentCategoryDataModel obj) { if (ModelState.IsValid) { DevelopmentCategoryDataManager.Create(obj, SessionVariables.RequestProfile); return(RedirectToAction("Index")); } return(View(obj)); }
public DevelopmentCategoryDataModel GetById(int id) { var obj = new DevelopmentCategoryDataModel(); obj.DevelopmentCategoryId = id; var list = DevelopmentCategoryDataManager.GetEntityDetails(obj, SessionVariables.RequestProfile); if (list == null || list.Count == 0) { return(null); } return(list[0]); }
public static void Delete(DevelopmentCategoryDataModel data, RequestProfile requestProfile) { const string sql = @"dbo.DevelopmentCategoryDelete "; var parameters = new { AuditId = requestProfile.AuditId , DevelopmentCategoryId = data.DevelopmentCategoryId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
static private List <DevelopmentCategoryDataModel> ToList(DataTable dt) { var list = new List <DevelopmentCategoryDataModel>(); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { var dataItem = new DevelopmentCategoryDataModel(); dataItem.DevelopmentCategoryId = (int?)dr[DevelopmentCategoryDataModel.DataColumns.DevelopmentCategoryId]; dataItem.DateCreated = (DateTime)dr[DevelopmentCategoryDataModel.DataColumns.DateCreated]; dataItem.DateModified = (DateTime)dr[DevelopmentCategoryDataModel.DataColumns.DateModified]; dataItem.CreatedByAuditId = (int?)dr[DevelopmentCategoryDataModel.DataColumns.CreatedByAuditId]; dataItem.ModifiedByAuditId = (int?)dr[DevelopmentCategoryDataModel.DataColumns.ModifiedByAuditId]; SetStandardInfo(dataItem, dr); list.Add(dataItem); } } return(list); }
public static List <DevelopmentCategoryDataModel> GetEntityDetails(DevelopmentCategoryDataModel dataQuery, RequestProfile requestProfile) { const string sql = @"dbo.DevelopmentCategorySearch "; var parameters = new { AuditId = requestProfile.AuditId , ApplicationId = requestProfile.ApplicationId , Name = dataQuery.Name , Description = dataQuery.Description , DevelopmentCategoryId = dataQuery.DevelopmentCategoryId , ApplicationMode = requestProfile.ApplicationModeId }; List <DevelopmentCategoryDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <DevelopmentCategoryDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
public static void Update(DevelopmentCategoryDataModel data, RequestProfile requestProfile) { var sql = CreateOrUpdate(data, requestProfile, "Update"); DBDML.RunSQL("DevelopmentCategory.Update", sql, DataStoreKey); }
public static string ToSQLParameter(DevelopmentCategoryDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case DevelopmentCategoryDataModel.DataColumns.DevelopmentCategoryId: if (data.DevelopmentCategoryId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, DevelopmentCategoryDataModel.DataColumns.DevelopmentCategoryId, data.DevelopmentCategoryId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DevelopmentCategoryDataModel.DataColumns.DevelopmentCategoryId); } break; case DevelopmentCategoryDataModel.DataColumns.DateCreated: if (data.DateCreated != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, DevelopmentCategoryDataModel.DataColumns.DateCreated, data.DateCreated); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DevelopmentCategoryDataModel.DataColumns.DateCreated); } break; case DevelopmentCategoryDataModel.DataColumns.DateModified: if (data.DateModified != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, DevelopmentCategoryDataModel.DataColumns.DateModified, data.DateModified); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DevelopmentCategoryDataModel.DataColumns.DateModified); } break; case DevelopmentCategoryDataModel.DataColumns.CreatedByAuditId: if (data.CreatedByAuditId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, DevelopmentCategoryDataModel.DataColumns.CreatedByAuditId, data.CreatedByAuditId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DevelopmentCategoryDataModel.DataColumns.CreatedByAuditId); } break; case DevelopmentCategoryDataModel.DataColumns.ModifiedByAuditId: if (data.ModifiedByAuditId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, DevelopmentCategoryDataModel.DataColumns.ModifiedByAuditId, data.ModifiedByAuditId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DevelopmentCategoryDataModel.DataColumns.ModifiedByAuditId); } break; default: returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
public static DevelopmentCategoryDataModel GetDetails(DevelopmentCategoryDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile); return(list.FirstOrDefault()); }