public void AddPart(ComputerPartDetail partDetail) { // update db int id = this._computerPartsService.Append(DTOConverter.FromComputerPartDetail(partDetail)); // update list view if within Condition/Type filters if ((Condition == "All" || Condition == partDetail.Condition) && (PartType == "All" || PartType == partDetail.PartType)) { ComputerPart part = new ComputerPart { Id = id, // on selected item (ListView), the id is use for edit or delete db query Description = partDetail.Description, Condition = partDetail.Condition, PartType = partDetail.PartType }; this.BoundedParts.Add(part); } }
public void EditPart(ComputerPart part, ComputerPartDetail partDetail) { // update db this._computerPartsService.Update(part.Id, DTOConverter.FromComputerPartDetail(partDetail)); // update list view if within Condition/Type filters if ((Condition == "All" || Condition == partDetail.Condition) && (PartType == "All" || PartType == partDetail.PartType)) { // update list view, boundedParts are updated automatically part.Description = partDetail.Description; part.Condition = partDetail.Condition; part.PartType = partDetail.PartType; } else { // otherwise, remove from list view this.BoundedParts.Remove(part); } }