Exemplo n.º 1
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> AddNewEmployee(EmployeeSubmitViewModel employee)
        {
            var newEmployee = await _employeeService.AddNewEmployeeAsync(employee);


            // Add action logic here
            return(View("Pages/Views/Employee.cshtml", newEmployee));
        }
Exemplo n.º 2
0
      /// <summary>
      /// Add New Employee and Dependents
      /// </summary>
      /// <param name="employeeSubmit"></param>
      /// <returns></returns>
      public async Task <EmployeeViewModel> AddNewEmployeeAsync(EmployeeSubmitViewModel employeeSubmit)
      {
          var addRequest = new AddNewEmployeeRequest
          {
              FirstName   = employeeSubmit.FirstName,
              LastName    = employeeSubmit.LastName,
              MiddleName  = employeeSubmit.MiddleName,
              DateOfBirth = employeeSubmit.DateOfBirth,
              Dependents  = employeeSubmit.Dependents
          };

          var client  = new RestClient("https://localhost:44361");
          var request = new RestRequest($"employee", Method.POST)
                        .AddJsonBody(addRequest);
          var employee = client.Execute(request);

          var responseContent = JsonConvert.DeserializeObject <AddNewEmployeeResponse>(employee.Content);

          var employeeProfile = await this.GetEmployeeProfileAsync(responseContent.EmployeeId);

          return(employeeProfile);
      }