public async Task <string> CreateEmployeeAsync(EmployeeCreationModel model) { var modelAsJson = JsonSerializer.Serialize(model); var content = new StringContent(modelAsJson, System.Text.Encoding.UTF8, "application/json"); var result = await _httpClient.PostAsync($"Employee/Create", content); return(await CheckAndProcessResultAsync(result)); }
public ActionResult Put(EmployeeCreationModel employeeModel) { if (ModelState.IsValid) { var employee = employeeModel.Adapt <Employee>(); _empoyeeRepository.Create(employee); return(Ok()); } return(BadRequest()); }
public static DomainEntity.Employee CreationToDomain(this EmployeeCreationModel @this) { return(new DomainEntity.Employee { birth_date = @this.birth_date, education = (DomainEntity.Education)(int) @this.education, first_name = @this.first_name, last_name = @this.last_name, registration_address = @this.registration_address, state = (DomainEntity.EmployeeState)(int) @this.state, date_on = DateTime.Now }); }
public async Task <IActionResult> Create([FromBody] EmployeeCreationModel model) { var createdEmployee = await _employeeStore.Insert(new Entitties.EmployeeEntity { Birthday = model.Birthday, City = model.City, CompanyName = model.CompanyName, FirstName = model.FirstName, LastName = model.LastName, Position = model.Position }); return(Json(createdEmployee)); }
private static async Task ProcessCommandAsync(EmployeeService employeeService, string command) { string result = string.Empty; if (command == "id") { Console.WriteLine("Press enter id to continue"); var c = Console.ReadLine(); result = await employeeService.GetEmployeeByIdAsync(int.Parse(c)); } if (command == "delete") { Console.WriteLine("Press enter id to continue"); var c = Console.ReadLine(); result = await employeeService.DeleteEmployeeAsync(int.Parse(c)); } if (command == "name") { Console.WriteLine("Press enter name to continue"); var c = Console.ReadLine(); result = await employeeService.GetEmployeeByNameAsync(c); } if (command == "all") { //result = await employeeService.GetAllEmployeeAsync(); } if (command == "create") { var model = new EmployeeCreationModel(); Console.WriteLine("Enter First:"); var firstName = Console.ReadLine(); model.FirstName = firstName; Console.WriteLine("Enter LastName:"); var lastName = Console.ReadLine(); model.LastName = lastName; Console.WriteLine("Enter CompanyName:"); var companyName = Console.ReadLine(); model.CompanyName = companyName; Console.WriteLine("Enter BirthDay:"); var birthDay = Console.ReadLine(); model.Birthday = DateTime.Parse(birthDay); result = await employeeService.CreateEmployeeAsync(model); } if (command == "q") { return; } Console.WriteLine(result); }
public EmployeeEntity Map(EmployeeCreationModel model) { string userName = model.LastName + model.FirstName[0]; if (string.IsNullOrEmpty(model.FirstName)) { userName = "******"; } return(new EmployeeEntity { CompanyName = model.CompanyName, FirstName = model.FirstName, LastName = model.LastName, Birthday = model.Birthday, UserName = userName, City = model.City, Position = model.Position }); }
public IHttpActionResult CreateEmployees([FromBody] EmployeeCreationModel model) { _employeeService.CreateEmployee(model.CreationToDomain()); return(new CreatedResult(Request)); }
public EmployeeEntity Create(EmployeeCreationModel model) { EmployeeEntity entity = _employeeMapper.Map(model); return(_employeeStore.Insert(entity)); }