public async void SeedData() { var employees = await _employeeService.BrowseAsync(); if (employees.Any()) { return; } await _employeeService.AddEmployeeAsync(new EmployeeDto { Id = Guid.NewGuid(), BirthDate = DateTime.ParseExact("1964-02-06", "yyyy-MM-dd", CultureInfo.InvariantCulture), FirstName = "Andrzej", LastName = "Wajda", NIP = "9714303042", Position = "Reżyser", Salary = 150000 }); await _employeeService.AddEmployeeAsync(new EmployeeDto { Id = Guid.NewGuid(), BirthDate = DateTime.ParseExact("1164-12-11", "yyyy-MM-dd", CultureInfo.InvariantCulture), FirstName = "Władysław", LastName = "Jagiełło", NIP = "9714303042", Position = "Krów", Salary = 644360000 }); await _employeeService.AddEmployeeAsync(new EmployeeDto { Id = Guid.NewGuid(), BirthDate = DateTime.ParseExact("1924-12-26", "yyyy-MM-dd", CultureInfo.InvariantCulture), FirstName = "Henryk", LastName = "Sienkiewicz", NIP = "7614203848", Position = "Pisarz", Salary = 230000 }); await _employeeService.AddEmployeeAsync(new EmployeeDto { Id = Guid.NewGuid(), BirthDate = DateTime.ParseExact("1214-02-06", "yyyy-MM-dd", CultureInfo.InvariantCulture), FirstName = "Adam", LastName = "Mickiewicz", NIP = "1191046053", Position = "Poeta", Salary = 1100 }); }
public async Task <ActionResult> CreateEmployeeAsync(EmployeeCreateDTO employeeDto) { var newEmployee = _mapper.Map <Employee>(employeeDto); var createdEmployee = await _employeeService.AddEmployeeAsync(newEmployee); return(Ok(createdEmployee)); }
public async Task <IActionResult> AddEmployee(EmployeeViewModel vm) { await eService.AddEmployeeAsync(vm.FirstName, vm.LastName, vm.StartingDate, vm.Salary, vm.VacationDays, byte.Parse(vm.ExperienceLevel)); var vm1 = new EmployeeSearchViewModel(); return(View("Index", vm1)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await _employeeService.AddEmployeeAsync(EmployeeDto); return(RedirectToPage("./Employees")); }
static async Task Main(string[] args) { for (int i = 0; i < 5; i++) { Thread.Sleep(100); } TcpChannel channel = new TcpChannel(0); ChannelServices.RegisterChannel(channel, false); Console.WriteLine("client start..."); IEmployeeService employeeService = CreateAsyncProxy <IEmployeeService>(); Debug.Assert(await employeeService.AddEmployeeAsync(new Employee() { Id = 1, Name = "zhangsan" })); Debug.Assert(!employeeService.AddEmployee(new Employee() { Id = 1, Name = "zhangsan" })); Debug.Assert(await employeeService.AddEmployeeAsync(new Employee() { Id = 2, Name = "lisi" })); Debug.Assert(employeeService.GetEmployee(1).Name == "zhangsan"); Debug.Assert((await employeeService.GetEmployeeAsync(2)).Name == "lisi"); DepartmentService departmentService = CreateAsyncProxy <DepartmentService>(); string name = await departmentService.GetNameAsync(); foreach (var employee in await departmentService.GetEmployeesByDepartmentNameAsync(name)) { Console.WriteLine(employee.Name); } Console.ReadKey(); }
public async Task <ActionResult <Employee> > PostAsync([FromBody] Employee employee) { try { await _employeeService.AddEmployeeAsync(employee); return(CreatedAtAction(nameof(Get), new { id = employee.EmployeeId }, employee)); } catch (Exception ex) { return(BadRequest(ex)); } }
public async Task <IActionResult> AddEmployee([FromBody] Employee employee) { int result; _logger.LogInformation("AddEmployee API was called"); result = await _employeeService.AddEmployeeAsync(employee); if (result == 0) { return(BadRequest()); } return(Ok()); }
public async Task <IHttpActionResult> AddEmployee([FromBody] Employee newEmployee) { try { IEmployee employee = newEmployee; var result = await _service.AddEmployeeAsync(employee); return(Ok(result)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IActionResult> Create(CreateEmployeeViewModel vm) { if (ModelState.IsValid) { var result = await _employeeService.AddEmployeeAsync(_mapper.Map <CreateEmployeeDTO>(vm)); return(result.IsValid ? RedirectToAction("Create") : _oops.OutPutError("Employee", "Create", result.ErrorsList)); } await FillingDropDownLists(); return(View("Create", vm)); }
public async Task <IActionResult> Create(CreateEmployeeViewModel vm) { if (ModelState.IsValid) { var model = _mapper.Map <CreateEmployeeDTO>(vm); var result = await _employeeService.AddEmployeeAsync(model); if (result.IsValid) { var ip = _accessor.HttpContext.Connection.RemoteIpAddress.ToString(); await _systemAuditService.AuditAsync(User.GetEmail(), ip, Operations.Insert, new[] { Tables.Employee, Tables.PositionEmployees }); if (model.TypeAccommodation == AccommodationType.Dormitory || model.TypeAccommodation == AccommodationType.Departmental) { await _systemAuditService.AuditAsync(User.GetEmail(), ip, Operations.Insert, Tables.PublicHouseEmployees); } else { await _systemAuditService.AuditAsync(User.GetEmail(), ip, Operations.Insert, Tables.PrivateHouseEmployees); } if (model.SocialActivity) { await _systemAuditService.AuditAsync(User.GetEmail(), ip, Operations.Insert, Tables.SocialActivityEmployees); } if (model.Privileges) { await _systemAuditService.AuditAsync(User.GetEmail(), ip, Operations.Insert, Tables.PrivilegeEmployees); } return(RedirectToAction("Create")); } TempData["ErrorsList"] = result.ErrorsList; } await FillingDropDownLists(); return(View(vm)); }
public async Task <ActionResult <EmployeeDto> > AddEmployeeAsync([FromBody] EmployeeAddRequest request) { var employeeDto = await _employeeService.AddEmployeeAsync(request); return(new ActionResult <EmployeeDto>(employeeDto)); }
public async Task <EmployeeViewModel> AddEmployee([FromBody] EmployeeViewModel employee) { return((EmployeeViewModel)await _employeeService.AddEmployeeAsync((Employee)employee)); }
public async Task <IActionResult> Create([FromBody] EmployeeDto employeeDto) { await _employeeService.AddEmployeeAsync(employeeDto); return(Ok()); }
public async Task <ActionResult> Post([FromBody] EmployeeModel model) { var result = await _employeeService.AddEmployeeAsync(model); return(new OkObjectResult(result)); }
public async Task <ServiceResponseModel <Employee> > AddEmployee(AddEmployeeModel addEmployeeModel) { return(await _employeeService.AddEmployeeAsync(addEmployeeModel)); }