// GET api/<controller>/5
        public IHttpActionResult Get(int id)
        {
            if (_mockRepo.Entities.Count() >= id && _mockRepo.Entities.Select(ent => _mockRepo.Entities.IndexOf(ent)).Contains(id))
            {
                taxedPayslipGenerator.SetTaxStrategy(new TaxStrategy2017(FINANCIAL_YEAR));

                return(Json(taxedPayslipGenerator.GeneratePayslip(_mockRepo.Entities[id])));
            }
            else
            {
                return(Json(new EmptyResult {
                    Message = "No such employee"
                }));
            }
        }
Exemple #2
0
 // GET api/<controller>/5
 public IHttpActionResult Get(int id)
 {
     using (var empContext = new EmployeeContext())
     {
         var employee = empContext.Employees.Find(id);
         if (employee != null)
         {
             taxedPayslipGenerator.SetTaxStrategy(new TaxStrategy2017(FINANCIAL_YEAR));
             return(Ok(taxedPayslipGenerator.GeneratePayslip(employee)));
         }
         else
         {
             return(NotFound());
         }
     }
 }