private void DeleteContractorSkill() { ContractorSkillColRows.AcceptChanges(); SkillColRows.AcceptChanges(); SelectedContractorSkill = new ContractorSkill(); SelectedContractorSkill.Delete(PassedContractorId, SelectedContractorSkillType); foreach (DataRow dr in ContractorSkillColRows.Rows) { // MessageBox.Show(dr[0].ToString()+ " " + SelectedContractorSkillType); // MessageBox.Show(SkillColRows.Rows.Count.ToString()); if (dr[0].ToString().Equals(SelectedContractorSkillType)) { DataRow dr1 = SkillColRows.NewRow(); dr1[0] = dr[0]; dr1[1] = dr[1]; SkillColRows.Rows.Add(dr1); //SkillColRows.Rows.Remove(dr); dr.Delete(); } } ContractorSkillColRows.AcceptChanges(); SkillColRows.AcceptChanges(); MessageBox.Show("Skill Removed", "Remove Contractor Skill", MessageBoxButton.OK, MessageBoxImage.Warning); }
public ContractorSkillViewModel(string ContractorId) { try { DAL dal = new DAL(); // we will pass sql to the database //DataTable dtfieldNames = dal.Read("select bit_skill.Skill_Id,bit_skill.Skill_Type from bit_contractor_skill,bit_skill WHERE bit_contractor_skill.Skill_Id = bit_skill.Skill_Id and Contractor_Id = 2"); DataTable dtfieldNames = dal.Read("select bit_contractor_skill.Skill_Id as Skill_Id,bit_skill.Skill_Type as Skill_Type from bit_contractor_skill,bit_skill WHERE bit_contractor_skill.Skill_Id = bit_skill.Skill_Id and Contractor_Id = " + ContractorId); PassedContractorId = Convert.ToInt32(ContractorId); // Add a message to the combobox for the user to select an Client // DataRow dtfieldNames1; //This is not putting our DataRow into the DataTable. Its just 'copying' the schema of the table to our row. // dtfieldNames1 = dtfieldNames.NewRow(); // dtfieldNames1["Skill_Id"] = "0"; // dtfieldNames1["Skill_Type"] = "-- Select a Skill Type--"; // Here We're 'inserting' the message into that column of the row // dtfieldNames.Rows.InsertAt(dtfieldNames1, 0); contractorSkillColRows = dtfieldNames; foreach (DataRow dr in dtfieldNames.Rows) { ContractorSkill skill = new ContractorSkill(dr); ContractorSkillCollection.Add(skill); } } catch (Exception ex) { MessageBox.Show("Could not Load Contractor Skill", "Loading Skill" + ex.Message); } LoadSkillTypeList(); }
public async Task <ContractorSkillOutput> Add(IContractor contractor, Guid skillId, ContractorSkillInput input) { var x1 = await Repository.Queryable() .Where(x => x.ContractorId == contractor.Id && x.SkillId == skillId) .FirstOrDefaultAsync(); if (x1 == null) { var entity = new ContractorSkill() { Created = DateTimeOffset.UtcNow, ObjectState = ObjectState.Added, ContractorId = contractor.Id, SkillId = skillId }.InjectFrom(input) as ContractorSkill; var result = await Repository.InsertAsync(entity, true); } var output = await Repository.Queryable() .Where(x => x.ContractorId == contractor.Id && x.SkillId == skillId) .ProjectTo <ContractorSkillOutput>(this.ProjectionMapping) .FirstAsync(); return(output); }