public List<ColorVM> GetRecords(int companyId) { //var oColors = new CSBC.Components.Color.ClsColors(); //DataTable rsData = new DataTable("Colors"); var rep = new ColorRepository(new CSBCDbContext()); var Colors = rep.GetAll(companyId); List<ColorVM> colorVm = new List<ColorVM>(); foreach(Color s in Colors) { var color = new ColorVM { ID = s.ID, ColorName = s.ColorName, Discontinued = s.Discontinued }; colorVm.Add(color); } return colorVm; }
private void LoadList() { ColorVM oColors = new ColorVM(); List<ColorVM> rsData = default(List<ColorVM>); try { /* rsData = oColors.GetRecords((int)Session["CompanyID"]); grdColors.Columns.Clear(); if (rsData.Count > 0) { grdColors.DataSource = rsData; grdColors.DataBind(); grdColors.Columns[0].Visible = false; */ // (0).].Visible = false; //.FromKey("ColorName").Header.Caption = "Color Name" //.FromKey("bDiscontinued").Hidden = True //.FromKey("sDiscontinued").Header.Caption = "Discontinued" //.FromKey("sDiscontinued").CellStyle.HorizontalAlign = HorizontalAlign.Center } catch (Exception ex) { lblError.Text = "LoadList::" + ex.Message; } finally { oColors = null; } }
private void LoadRow(long RowID) { //Website.ClsColors oColor = new Website.ClsColors(); //DataTable rsData = default(DataTable); ColorVM oColors = new ColorVM(); List<ColorVM> rsData = default(List<ColorVM>); try { //rsData = oColor.LoadColors(RowID, Session["CompanyID"]) if ((rsData != null)) { if (rsData.Count > 0) { lblID.Text = rsData[0].ID.ToString(); txtName.Text = rsData[0].ColorName; chkDiscontinue.Checked = (bool)rsData[0].Discontinued; } } } catch (Exception ex) { lblError.Text = "LoadRow::" + ex.Message; } }
public void GetColorVMTest() { var rep = new ColorVM(); var colors = rep.GetRecords(1); Assert.IsTrue(colors.Count > 1); }