public async Task <ActionResult> CreateAsync(EmployeeTasksViewModel employeeTasksViewModel) { _logger.LogInformation("Creating New Employee Task"); bool isEmployeeHaveCapacity = true; isEmployeeHaveCapacity = await IsEmployeeAvailable(employeeTasksViewModel, isEmployeeHaveCapacity); //checking model state if (ModelState.IsValid) { if (isEmployeeHaveCapacity) { try { await GetCurrentRatePerHour(employeeTasksViewModel); var emp = await this.employeeTaskService.CreateEmployeeTask(_objectMapper.EmployeeTasksViewModelToEmployeeTasks(employeeTasksViewModel)); return(RedirectToAction("Index")); } catch (Exception ex) { _logger.LogError("Error Creating Employee Task {0}", ex.Message); return(View(ex.InnerException.Message)); } } else { ModelState.AddModelError("TotalNoOfHours", "Employee doesnt have capacity to Assgin this task"); } } EmployeeTasksViewModel empTaskView = await LoadEmployeeDetails(); return(View(empTaskView)); }