public bool Update(ProjectsEntity model) { this.ClearBrokenRuleMessages(); BaseValidator <ProjectsEntity> validator = new UpdateProjectValidator(); if (!validator.Validate(model)) { this.AddBrokenRuleMessages(validator.BrokenRuleMessages); return(false); } if (projResp.CheckExistsTitle(model.Title, model.ID)) { this.AddBrokenRuleMessage("Error", "Project title existed!Please input a new one."); return(false); } if (projResp.CheckExistsCode(model.ProjectCode, model.ID)) { this.AddBrokenRuleMessage("Error", "Project code existed!Please input a new one."); return(false); } if (!projResp.Update(model)) { this.AddBrokenRuleMessage(); return(false); } cache[CACHE_PROJECTLIST_KEY] = null; return(true); }
public int Insert(ProjectsEntity model) { this.ClearBrokenRuleMessages(); BaseValidator <ProjectsEntity> validator = new AddProjectValidator(); if (!validator.Validate(model)) { this.AddBrokenRuleMessages(validator.BrokenRuleMessages); return(0); } if (projResp.CheckExistsTitle(model.Title, 0)) { this.AddBrokenRuleMessage("Error", "Project title existed!Please input a new one."); return(0); } if (projResp.CheckExistsCode(model.ProjectCode, 0)) { this.AddBrokenRuleMessage("Error", "Project code existed!Please input a new one."); return(0); } int id = projResp.Insert(model); if (id <= 0) { this.AddBrokenRuleMessage(); return(0); } model.ProjectID = id; model.ID = id; ClearCache(); return(id); }
public ProjectsEntity Get(int id, string connStr = "") { if (id < 0) { return(null); } this.ClearBrokenRuleMessages(); List <ProjectDetailDTO> list = GetAllProjects(); if (list == null || list.Count == 0) { return(null); } ProjectsEntity model = list.Find(r => r.ProjectID == id); if (model == null) { this.AddBrokenRuleMessage(); } return(model); }
/// <summary> /// Bind IDataReader to Entity /// </summary> public static ProjectsEntity ReaderBind(IDataReader dataReader) { ProjectsEntity model = new ProjectsEntity(); object ojb; ojb = dataReader["ProjectID"]; if (ojb != null && ojb != DBNull.Value) { model.ProjectID = (int)ojb; } ojb = dataReader["CompanyID"]; if (ojb != null && ojb != DBNull.Value) { model.CompanyID = (int)ojb; } model.ProjectCode = dataReader["ProjectCode"].ToString(); model.Title = dataReader["Title"].ToString(); model.Description = dataReader["Description"].ToString(); ojb = dataReader["StartDate"]; if (ojb != null && ojb != DBNull.Value) { model.StartDate = (DateTime)ojb; } ojb = dataReader["EndDate"]; if (ojb != null && ojb != DBNull.Value) { model.EndDate = (DateTime)ojb; } ojb = dataReader["Status"]; if (ojb != null && ojb != DBNull.Value) { model.Status = (int)ojb; } ojb = dataReader["CreatedBy"]; if (ojb != null && ojb != DBNull.Value) { model.CreatedBy = (int)ojb; } ojb = dataReader["CreatedOn"]; if (ojb != null && ojb != DBNull.Value) { model.CreatedOn = (DateTime)ojb; } ojb = dataReader["ModifiedBy"]; if (ojb != null && ojb != DBNull.Value) { model.ModifiedBy = (int)ojb; } ojb = dataReader["ModifiedOn"]; if (ojb != null && ojb != DBNull.Value) { model.ModifiedOn = (DateTime)ojb; } ojb = dataReader["PMID"]; if (ojb != null && ojb != DBNull.Value) { model.PMID = (int)ojb; } model.Priority = dataReader["Priority"].ToString(); ojb = dataReader["Billable"]; if (ojb != null && ojb != DBNull.Value) { model.Billable = (bool)ojb; } model.TestLinkURL = dataReader["TestLinkURL"].ToString(); model.TestUserName = dataReader["TestUserName"].ToString(); model.TestPassword = dataReader["TestPassword"].ToString(); ojb = dataReader["FreeHour"]; if (ojb != null && ojb != DBNull.Value) { model.FreeHour = (int)ojb; } ojb = dataReader["BugNeedApproved"]; if (ojb != null && ojb != DBNull.Value) { model.BugNeedApproved = (bool)ojb; } ojb = dataReader["RequestNeedApproved"]; if (ojb != null && ojb != DBNull.Value) { model.RequestNeedApproved = (bool)ojb; } ojb = dataReader["IsOverFreeTime"]; if (ojb != null && ojb != DBNull.Value) { model.IsOverFreeTime = (bool)ojb; } return(model); }