public ActionResult Index2(string searchString, int?page, int?pageSize) { var obj = new ReleaseNoteLogisticsDifficultyDataModel(); obj.Name = searchString; var list = ReleaseNoteLogisticsDifficultyDataManager.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 List<ReleaseNoteLogisticsDifficultyDataModel> GetEntityDetails(ReleaseNoteLogisticsDifficultyDataModel data, RequestProfile requestProfile) //{ // var dt = GetDetails(data, requestProfile.AuditId); // var list = ToList(dt); // return list; //} #endregion GetDetails #region CreateOrUpdate private static string CreateOrUpdate(ReleaseNoteLogisticsDifficultyDataModel data, RequestProfile requestProfile, string action) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.ReleaseNoteLogisticsDifficultyInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.ReleaseNoteLogisticsDifficultyUpdate " + "\r\n" + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) + ", " + ToSQLParameter(data, ReleaseNoteLogisticsDifficultyDataModel.DataColumns.ReleaseNoteLogisticsDifficultyId) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder); return(sql); }
static private List <ReleaseNoteLogisticsDifficultyDataModel> ToList(DataTable dt) { var list = new List <ReleaseNoteLogisticsDifficultyDataModel>(); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { var dataItem = new ReleaseNoteLogisticsDifficultyDataModel(); dataItem.ReleaseNoteLogisticsDifficultyId = (int?)dr[ReleaseNoteLogisticsDifficultyDataModel.DataColumns.ReleaseNoteLogisticsDifficultyId]; dataItem.DateCreated = (DateTime)dr[ReleaseNoteLogisticsDifficultyDataModel.DataColumns.DateCreated]; dataItem.DateModified = (DateTime)dr[ReleaseNoteLogisticsDifficultyDataModel.DataColumns.DateModified]; dataItem.CreatedByAuditId = (int?)dr[BaseDataModel.BaseDataColumns.CreatedByAuditId]; dataItem.ModifiedByAuditId = (int?)dr[BaseDataModel.BaseDataColumns.ModifiedByAuditId]; SetStandardInfo(dataItem, dr); SetBaseInfo(dataItem, dr); list.Add(dataItem); } } return(list); }
public static int Create(ReleaseNoteLogisticsDifficultyDataModel data, RequestProfile requestProfile) { var sql = CreateOrUpdate(data, requestProfile, "Create"); var ReleaseNoteLogisticsDifficultyId = DBDML.RunScalarSQL("ReleaseNoteLogisticsDifficulty.Insert", sql, DataStoreKey); return(Convert.ToInt32(ReleaseNoteLogisticsDifficultyId)); }
public static DataTable DoesExist(ReleaseNoteLogisticsDifficultyDataModel data, RequestProfile requestProfile) { var doesExistRequest = new ReleaseNoteLogisticsDifficultyDataModel(); doesExistRequest.Name = data.Name; return(Search(doesExistRequest, requestProfile)); }
public static DataTable Search(ReleaseNoteLogisticsDifficultyDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 0); var table = list.ToDataTable(); return(table); }
static public List <ReleaseNoteLogisticsDifficultyDataModel> GetEntitySearch(ReleaseNoteLogisticsDifficultyDataModel obj, RequestProfile requestProfile) { var dt = Search(obj, requestProfile); var list = ToList(dt); return(list); }
public JsonResult IndexResult(string name, int?page, int?pageSize) { var obj = new ReleaseNoteLogisticsDifficultyDataModel(); obj.Name = name; var list = ReleaseNoteLogisticsDifficultyDataManager.GetEntitySearch(obj, SessionVariables.RequestProfile); return(Json(list, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(ReleaseNoteLogisticsDifficultyDataModel obj) { if (ModelState.IsValid) { ReleaseNoteLogisticsDifficultyDataManager.Create(obj, SessionVariables.RequestProfile); return(RedirectToAction("Index")); } return(View(obj)); }
public static bool DoesExist(ReleaseNoteLogisticsDifficultyDataModel data, RequestProfile requestProfile) { var doesExistRequest = new ReleaseNoteLogisticsDifficultyDataModel(); doesExistRequest.Name = data.Name; var list = GetEntityDetails(doesExistRequest, requestProfile, 0); return(list.Count > 0); }
public ReleaseNoteLogisticsDifficultyDataModel GetById(int id) { var obj = new ReleaseNoteLogisticsDifficultyDataModel(); obj.ReleaseNoteLogisticsDifficultyId = id; var list = ReleaseNoteLogisticsDifficultyDataManager.GetEntityDetails(obj, SessionVariables.RequestProfile); if (list == null || list.Count == 0) { return(null); } return(list[0]); }
public static void Delete(ReleaseNoteLogisticsDifficultyDataModel data, RequestProfile requestProfile) { const string sql = @"dbo.ReleaseNoteLogisticsDifficultyDelete "; var parameters = new { AuditId = requestProfile.AuditId , ReleaseNoteLogisticsDifficultyId = data.ReleaseNoteLogisticsDifficultyId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
public static string ToSQLParameter(ReleaseNoteLogisticsDifficultyDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case ReleaseNoteLogisticsDifficultyDataModel.DataColumns.ReleaseNoteLogisticsDifficultyId: if (data.ReleaseNoteLogisticsDifficultyId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, ReleaseNoteLogisticsDifficultyDataModel.DataColumns.ReleaseNoteLogisticsDifficultyId, data.ReleaseNoteLogisticsDifficultyId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ReleaseNoteLogisticsDifficultyDataModel.DataColumns.ReleaseNoteLogisticsDifficultyId); } break; case ReleaseNoteLogisticsDifficultyDataModel.DataColumns.DateCreated: if (data.DateCreated != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, ReleaseNoteLogisticsDifficultyDataModel.DataColumns.DateCreated, data.DateCreated); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ReleaseNoteLogisticsDifficultyDataModel.DataColumns.DateCreated); } break; case ReleaseNoteLogisticsDifficultyDataModel.DataColumns.DateModified: if (data.DateModified != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, ReleaseNoteLogisticsDifficultyDataModel.DataColumns.DateModified, data.DateModified); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ReleaseNoteLogisticsDifficultyDataModel.DataColumns.DateModified); } break; default: returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
public static void Update(ReleaseNoteLogisticsDifficultyDataModel data, RequestProfile requestProfile) { var sql = CreateOrUpdate(data, requestProfile, "Update"); DBDML.RunSQL("ReleaseNoteLogisticsDifficulty.Update", sql, DataStoreKey); }
public static ReleaseNoteLogisticsDifficultyDataModel GetDetails(ReleaseNoteLogisticsDifficultyDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 1); return(list.FirstOrDefault()); }
public static List <ReleaseNoteLogisticsDifficultyDataModel> GetEntityDetails(ReleaseNoteLogisticsDifficultyDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails) { const string sql = @"dbo.ReleaseNoteLogisticsDifficultySearch "; var parameters = new { AuditId = requestProfile.AuditId , ReleaseNoteLogisticsDifficultyId = dataQuery.ReleaseNoteLogisticsDifficultyId , ReturnAuditInfo = returnAuditInfo , Name = dataQuery.Name , Description = dataQuery.Description , ApplicationId = requestProfile.ApplicationId }; List <ReleaseNoteLogisticsDifficultyDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <ReleaseNoteLogisticsDifficultyDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
static public List <ReleaseNoteLogisticsDifficultyDataModel> GetEntitySearch(ReleaseNoteLogisticsDifficultyDataModel obj, RequestProfile requestProfile) { return(GetEntityDetails(obj, requestProfile, 0)); }