public async Task <IActionResult> PutTaxablePerson(int id, TaxablePerson taxablePerson) { if (id != taxablePerson.Id) { return(BadRequest()); } _context.Entry(taxablePerson).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaxablePersonExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <TaxablePerson> > PostTaxablePerson(TaxablePerson taxablePerson) { _context.TaxablePerson.Add(taxablePerson); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TaxablePersonExists(taxablePerson.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetTaxablePerson", new { id = taxablePerson.Id }, taxablePerson)); }
public async Task <ActionResult <IEnumerable <TaxablePerson> > > GetTaxablePerson([FromQuery] TaxablePerson taxable) { IQueryable <TaxablePerson> taxableperson = _context.TaxablePerson; if (taxable.GrossWage > 0) { taxableperson = taxableperson.Where( i => i.GrossWage.Equals(taxable.GrossWage)); } if (taxable.Tax >= 0) { taxableperson = taxableperson.Where( i => i.Tax.Equals(taxable.Tax)); } if (taxable.PersonTypeId >= 1) { taxableperson = taxableperson.Where( i => i.PersonTypeId.Equals(taxable.PersonTypeId)); } return(await taxableperson.ToListAsync()); }