public Result <List <Diem_ett> > select_by_fields(string input, string how) { Result <List <Diem_ett> > rs = new Result <List <Diem_ett> >(); try { List <Diem_ett> lst = new List <Diem_ett>(); IQueryable <tbl_diem> dt = null; switch (how) { case "masv": dt = db.tbl_diems.Where(o => o.masv.Contains(input)); break; case "tensv": break; case "mamon": dt = db.tbl_diems.Where(o => o.mamon.Contains(input)); break; case "tenmon": break; case "diem": dt = db.tbl_diems.Where(o => o.diem.Contains(input)); break; default: break; } if (dt.Count() > 0) { foreach (tbl_diem item in dt) { Diem_ett temp = new Diem_ett(item); lst.Add(temp); } rs.data = lst; rs.errorCode = ErrorCode.Sucess; } else { rs.data = null; rs.errorCode = ErrorCode.NaN; rs.errorInfor = Constants.empty_data; } return(rs); } catch (Exception e) { rs.data = null; rs.errorCode = ErrorCode.False; rs.errorInfor = e.ToString(); return(rs); } }
public Result <List <Diem_ett> > select_all_diem() { Result <List <Diem_ett> > rs = new Result <List <Diem_ett> >(); try { List <Diem_ett> lst = new List <Diem_ett>(); var dt = db.tbl_diems; if (dt.Count() > 0) { foreach (tbl_diem item in dt) { Diem_ett temp = new Diem_ett(item); lst.Add(temp); } rs.data = lst; rs.errorCode = ErrorCode.Sucess; } else { rs.data = null; rs.errorCode = ErrorCode.NaN; rs.errorInfor = Constants.empty_data; } return(rs); } catch (Exception e) { rs.data = null; rs.errorCode = ErrorCode.False; rs.errorInfor = e.ToString(); return(rs); } }