public void InsertGroup() { var group = new EngineerGroup(0, "My 2nd Group", "This is another test group", true); group.Insert(); Assert.AreNotEqual(0, group.GroupId, "the groupid is still 0"); }
protected void btnAdd_Click(object sender, System.EventArgs e) { if (string.IsNullOrEmpty(txtName.Text.Trim())) { return; } var newGroup = new EngineerGroup(); newGroup.Name = txtName.Text; newGroup.Description = txtDescription.Text; newGroup.Insert(); RefreshPage(); }
public static EngineerGroup GetById(int groupId) { var group = new EngineerGroup(); using (var con = new SqlConnection(Configuration.ConnectionString)) { con.Open(); Dictionary<string, string> @params = new Dictionary<string, string>(); @params.Add("@GroupID", groupId.ToString()); var reader = GetDataReaderByStoredProcedure("sp_tblEngineerGroup_GetById", @params, con); if (reader.HasRows) { reader.Read(); group.GroupId = reader.GetValueOrDefault<int>("ID"); group.Name = reader.GetValueOrDefault<string>("Name"); group.Description = reader.GetValueOrDefault<string>("Description"); group.IsActive = reader.GetValueOrDefault<bool>("Active"); group.Members = EngineerGroupMember.GetByGroupId(groupId); } con.Close(); } return group; }
private void GetGroup() { int groupId = 0; if (int.TryParse(hdnGroupFilterId.Value, out groupId)) { if (groupId > 0) { _filterGroup = EngineerGroup.GetById(groupId); } } }