public bool DeleteTax(string id) { using (var ctx = new SalaryManagement_SWD391_ProjectEntities_Tax()) { var tax = ctx.PersonalIncomeTaxes.Where(c => c.TaxID == id).FirstOrDefault(); ctx.Entry(tax).State = System.Data.Entity.EntityState.Deleted; ctx.SaveChanges(); return(true); } }
public bool CreateTax(PersonalIncomeTax personalIncomeTax) { using (var ctx = new SalaryManagement_SWD391_ProjectEntities_Tax()) { ctx.PersonalIncomeTaxes.Add(new PersonalIncomeTax() { TaxID = personalIncomeTax.TaxID, TaxDetail = personalIncomeTax.TaxDetail, Coefficient = personalIncomeTax.Coefficient }); ctx.SaveChanges(); } return(true); }
public bool UpdateTax(PersonalIncomeTaxModel personalIncomeTax) { using (var ctx = new SalaryManagement_SWD391_ProjectEntities_Tax()) { var checkExistingTax = ctx.PersonalIncomeTaxes.Where(c => c.TaxID == personalIncomeTax.TaxID).FirstOrDefault <PersonalIncomeTax>(); if (checkExistingTax != null) { checkExistingTax.TaxDetail = personalIncomeTax.TaxDetail; checkExistingTax.Coefficient = (double)personalIncomeTax.Coefficient; ctx.SaveChanges(); return(true); } else { return(false); } } }