public bool DeleteTaxSlab(int taxSlabId) { try { int taxSlabCount = TaxSlabTestData.RemoveAll(tax => tax.Id == taxSlabId); int taxSlabDetailCount = TaxSlabDetailTestData.RemoveAll(tax => tax.TaxSlabId == taxSlabId); return(Convert.ToBoolean(taxSlabCount + taxSlabDetailCount)); } catch (Exception) { return(false); } }
public int InsertUpdateTaxSlab(TaxSlab taxSlab, IEnumerable <TaxSlabDetail> taxSlabDetails) { if (taxSlab.Id == -1) { taxSlab.Id = TaxSlabTestData.Max(ts => ts.Id) + 1; TaxSlabTestData.Add(taxSlab); TaxSlabDetailTestData.AddRange(taxSlabDetails); } else { var obj = TaxSlabTestData.FirstOrDefault(ts => ts.Id == taxSlab.Id); if (obj != null) { obj = taxSlab; //var index = TaxSlabTestData.Select((ts, ind) => new { Index = ind }).FirstOrDefault().Index; //TaxSlabTestData[index] = taxSlab; } } return(taxSlab.Id); }