Example #1
0
        public async Task <IActionResult> InsertEmployee([FromBody] Entities.Concrete.Employee.Employee employeeRequest)
        {
            ActionResultResponse <EmployeeResponse> response;

            Entities.Concrete.Employee.Employee employee = null;
            try
            {
                if (_service.ValidateEmployee(employeeRequest.CompanyID, employeeRequest.UserName, false))
                {
                    if (_service.InsertEmployee(employeeRequest))
                    {
                        employee = _service.GetEmployeeByCompanyID(employeeRequest.CompanyID);
                    }
                    response = EmployeeMapper.EmployeeGetByIdResult(employee);
                }
                else
                {
                    response = new ActionResultResponse <EmployeeResponse>(System.Net.HttpStatusCode.Locked, MessageException.GetEmployeeAlreadyExists(employeeRequest.CompanyID, employeeRequest.UserName), null);
                }
            }
            catch (Exception ex)
            {
                LogException.WriteLog(ex, "EmployeeController.InsertEmployee", JsonSerializer.Serialize(employeeRequest), LogType.Error);
                response = new ActionResultResponse <EmployeeResponse>(System.Net.HttpStatusCode.InternalServerError, MessageException.GetGeneralMessage(ex), null);
            }
            return(GetResponse(response));
        }
Example #2
0
        public async Task <IActionResult> GetDummyEmployee()
        {
            Entities.Concrete.Employee.Employee     employee = new Entities.Concrete.Employee.Employee();
            ActionResultResponse <EmployeeResponse> response;

            try
            {
                response = EmployeeMapper.EmployeeGetByIdResult(employee);
            }
            catch (Exception ex)
            {
                LogException.WriteLog(ex, "EmployeeController.InsertEmployee", JsonSerializer.Serialize(employee), LogType.Error);
                response = new ActionResultResponse <EmployeeResponse>(System.Net.HttpStatusCode.InternalServerError, MessageException.GetGeneralMessage(ex), null);
            }
            return(GetResponse(response));
        }