//public bool Delete(int id) //{ // var result = new Result<COMMENTSEC>(); // try // { // string query = "delete from COMMENTSEC where CommunicationId=" + id; // return DataAccess.ExecuteQuery(query) > 0; // } // catch (Exception ex) // { // return false; // } //} private bool IsValid(COMMENTSEC obj, Result <COMMENTSEC> result) { if (!ValidationHelper.IsStringValid(obj.Commt)) { result.HasError = true; result.Message = "Invalid School Name"; return(false); } return(true); }
private COMMENTSEC ConvertToEntity(DataRow row) { try { COMMENTSEC u = new COMMENTSEC(); u.CommunicationId = Int32.Parse(row["CommunicationId"].ToString()); u.UserId = Int32.Parse(row["UserID"].ToString()); u.ProjectSectionId = Int32.Parse(row["ProjectSectionId"].ToString()); u.Commt = row["Commt"].ToString(); return(u); } catch (Exception) { return(null); } }
public Result <COMMENTSEC> Save(COMMENTSEC COMMENTSEC) { var result = new Result <COMMENTSEC>(); try { string query = "select * from COMMENTSEC where CommunicationId=" + COMMENTSEC.CommunicationId; var dt = DataAccess.GetDataTable(query); if (dt == null || dt.Rows.Count == 0) { COMMENTSEC.CommunicationId = GetID(); query = "insert into COMMENTSEC values(" + COMMENTSEC.CommunicationId + "," + COMMENTSEC.UserId + "," + COMMENTSEC.ProjectSection + ",'" + COMMENTSEC.Commt + "')"; } //else //{ // query = "update COMMENTSEC set ProjectName='" + COMMENTSEC.ProjectName + "',StartTime='" + COMMENTSEC.StartTime + "',EndTime='" + COMMENTSEC.EndTime + "',Description='" + COMMENTSEC.Description + "',ProjectSection='" + COMMENTSEC.ProjectSection + "',Price=" + COMMENTSEC.Price + ",Members=" + COMMENTSEC.Members + " where PostID=" + COMMENTSEC.PostId; //} if (!IsValid(COMMENTSEC, result)) { return(result); } result.HasError = DataAccess.ExecuteQuery(query) <= 0; if (result.HasError) { result.Message = "Something Went Wrong"; } else { result.Data = COMMENTSEC; } } catch (Exception ex) { result.HasError = true; result.Message = ex.Message; } return(result); }
public List <COMMENTSEC> GetAll(int id) { var result = new List <COMMENTSEC>(); try { string query = "select * from COMMENTSEC where PROJECTSECID=" + id; var dt = DataAccess.GetDataTable(query); if (dt != null && dt.Rows.Count != 0) { for (int i = 0; i < dt.Rows.Count; i++) { COMMENTSEC u = ConvertToEntity(dt.Rows[i]); result.Add(u); } } } catch (Exception ex) { return(result); } return(result); }