public IdentityProjectCategory GetById(int Id) { var sqlCmd = @"ProjectCategory_GetById"; IdentityProjectCategory info = null; var paramaters = new Dictionary <string, object> { { "Id", Id } }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, paramaters)) { if (reader.Read()) { info = ExtractProjectCategory(reader); } } } } catch (Exception ex) { var strError = "Failed to execute ProjectCategory_GetById. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public int Insert(IdentityProjectCategory identity) { var sqlCmd = @"ProjectCategory_Insert"; var newId = 0; var paramaters = new Dictionary <string, object> { { "Code", identity.Code }, { "Name", identity.Name }, { "Status", identity.Status }, }; try { using (var connn = new SqlConnection(_connectionString)) { var returnObj = MsSqlHelper.ExecuteScalar(connn, CommandType.StoredProcedure, sqlCmd, paramaters); newId = Convert.ToInt32(returnObj); } } catch (Exception ex) { var strError = "Failed to execute ProjectCategory_Insert. Error: " + ex.Message; throw new CustomSQLException(strError); } return(newId); }
public List <IdentityProjectCategory> GetByPage(IdentityProjectCategory filter, int currentPage, int pageSize) { var sqlCmd = @"ProjectCategory_GetByPage"; int offset = (currentPage - 1) * pageSize; List <IdentityProjectCategory> listData = null; var paramaters = new Dictionary <string, object> { { "@Keyword", filter.Keyword }, { "@Status", filter.Status }, { "@Offset", offset }, { "@PageSize", pageSize }, }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, paramaters)) { listData = ParsingListFromReader(reader); } } } catch (Exception ex) { var strError = "Failed to execute ProjectCategory_GetByPage. Error: " + ex.Message; throw new CustomSQLException(strError); } return(listData); }
public bool Update(IdentityProjectCategory identity) { var sqlCmd = @"ProjectCategory_Update"; var paramaters = new Dictionary <string, object> { { "Id", identity.Id }, { "Code", identity.Code }, { "Name", identity.Name }, { "Status", identity.Status }, }; try { using (var conn = new SqlConnection(_connectionString)) { MsSqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, sqlCmd, paramaters); } } catch (Exception ex) { var strError = "Failed to execute ProjectCategory_Update. Error: " + ex.Message; throw new CustomSQLException(strError); } return(true); }
public ProjectCategoryEditMode RenderEditProjectCategory(IdentityProjectCategory identity) { var editModel = new ProjectCategoryEditMode(); editModel.Code = identity.Code; editModel.Name = identity.Name; editModel.Status = identity.Status; return(editModel); }
public IdentityProjectCategory ExtractCreateFormData(ProjectCategoryCreateModel formData) { var myIdentity = new IdentityProjectCategory(); myIdentity.Code = formData.Code; myIdentity.Name = formData.Name; myIdentity.Status = formData.Status; return(myIdentity); }
public IdentityProjectCategory ExtractEditFromData(ProjectCategoryEditMode formData) { var myIdentity = new IdentityProjectCategory(); myIdentity.Id = formData.Id; myIdentity.Code = formData.Code; myIdentity.Name = formData.Name; myIdentity.Status = formData.Status; return(myIdentity); }
public static IdentityProjectCategory ExtractProjectCategory(IDataReader reader) { var record = new IdentityProjectCategory(); record.Id = Utils.ConvertToInt32(reader["Id"]); record.Code = reader["Code"].ToString(); record.Name = reader["Name"].ToString(); record.CreatedDate = reader["CreatedDate"] == DBNull.Value ? null : (DateTime?)reader["CreatedDate"]; record.Status = Utils.ConvertToInt32(reader["Status"]); return(record); }
// GET: ProjectCategory public ActionResult Index(ManageProjectCategoryModel model) { int currentPage = 1; int pageSize = SystemSettings.DefaultPageSize; if (string.IsNullOrEmpty(model.SearchExec)) { model.SearchExec = "Y"; if (!ModelState.IsValid) { ModelState.Clear(); } } if (Request["Page"] != null) { currentPage = Utils.ConvertToInt32(Request["Page"], 1); } var filter = new IdentityProjectCategory { Keyword = !string.IsNullOrEmpty(model.Keyword) ? model.Keyword.Trim() : null, Status = model.Status == null ? -1 : (int)model.Status, }; try { model.SearchResults = _mainStore.GetByPage(filter, currentPage, SystemSettings.DefaultPageSize); if (model.SearchResults != null && model.SearchResults.Count > 0) { model.TotalCount = model.SearchResults[0].TotalCount; model.CurrentPage = currentPage; model.PageSize = pageSize; } } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed to get data because: " + ex.ToString()); return(View(model)); } return(View(model)); }
public bool Update(IdentityProjectCategory identity) { return(myRepository.Update(identity)); }
public int Insert(IdentityProjectCategory identity) { return(myRepository.Insert(identity)); }
public List <IdentityProjectCategory> GetByPage(IdentityProjectCategory filter, int currentPage, int pageSize) { return(myRepository.GetByPage(filter, currentPage, pageSize)); }