public IHttpActionResult Index(bool fired = false) { var empls = _mapper.Map <IEnumerable <IndexEmployeeViewModel> >(_service.GetAll()); foreach (var emp in empls) { emp.OnVacation = _vacationService.CheckOnVacation(DateTime.Now, emp.Id); } if (fired) { return(Ok(empls.Where(x => x.Fired))); } if (!fired) { return(Ok(empls.Where(x => !x.Fired))); } return(Ok(empls)); }
public ActionResult Index(string fired) { ViewBag.Filter = string.IsNullOrEmpty(fired) ? "all" : fired; var empls = _mapper.Map <IEnumerable <IndexEmployeeViewModel> >(_service.GetAll()); foreach (var emp in empls) { emp.OnVacation = _vacationService.CheckOnVacation(DateTime.Now, emp.Id); } if (string.Equals(fired, "fired")) { return(View(empls.Where(x => x.Fired))); } if (string.Equals(fired, "unfired")) { return(View(empls.Where(x => !x.Fired))); } return(View(empls)); }