private void Save(object obj)
        {
            if (!isNew)
            {
                Employee emp = new Employee();
                emp.Id           = SelectedEmployee.Id;
                emp.FirstName    = FirstName;
                emp.LastName     = LastName;
                emp.Salary       = Salary;
                emp.Age          = Age;
                emp.City         = City;
                emp.EnterpriseId = SelectedEnterprise.Id;
                //emp.Enterprise = SelectedEnterprise;

                Client.UpdateEmployee(emp, emp.Id);
            }
            else
            {
                Employee emp = new Employee();
                {
                    emp.FirstName    = FirstName;
                    emp.LastName     = LastName;
                    emp.Salary       = Salary;
                    emp.Age          = Age;
                    emp.City         = City;
                    emp.EnterpriseId = SelectedEnterprise.Id;
                    // emp.Enterprise = SelectedEnterprise;
                }

                Client.AddEmployee(emp);
            }
            Init();
            Window.GetWindow(((System.Windows.Controls.Button)obj)).Close();
            SelectedEmployee = null;
        }
예제 #2
0
        public async Task <IActionResult> AddEmployeeAsync([FromForm] Employee employee)
        {
            try
            {
                Employee addedEmployee = await _empService.AddEmployee(employee);

                if (addedEmployee == null)
                {
                    return(BadRequest(new Response <Employee>(null, (int)HttpStatusCode.BadRequest, ResponseMessages.FAILED)));
                }
                return(Ok(new Response <Employee>(addedEmployee, (int)HttpStatusCode.OK, ResponseMessages.SUCCESSFULL)));
            }
            catch (Exception e)
            {
                return(BadRequest(new Response <Employee>(null, (int)HttpStatusCode.InternalServerError, e.Message)));
            }
        }