public async Task <Employee> AddEmployeeAsync(AddEmployeeModel addEmployeeModel) { var employeeList = await GetEmployeesAsync(); if (addEmployeeModel == null) { return(new Employee()); } var employee = new Employee() { Id = employeeList.Max(i => i.Id) + 1, FirstName = addEmployeeModel.FirstName, LastName = addEmployeeModel.LastName, DateOfBirth = addEmployeeModel.DateOfBirth, StartDate = addEmployeeModel.StartDate, EndDate = addEmployeeModel.EndDate, Department = addEmployeeModel.Department, Designation = addEmployeeModel.Designation, ManagerId = addEmployeeModel.ManagerId, HourlyRate = addEmployeeModel.HourlyRate }; employeeList.Add(employee); SaveEmploye(employeeList); return(employee); }
public IActionResult Add(AddEmployeeModel employee) { EmployeeBusiness employeeBusiness = new EmployeeBusiness(); var result = employeeBusiness.AddEmployee(employee); return(Ok(result)); }
public ReturnResult <Employee> Add(AddEmployeeModel employee) { DbProvider dbProvider = new DbProvider(); string outCode = String.Empty; string outMessage = String.Empty; StoredProcedureConfigs <Employee> storedProcedureConfigs = new StoredProcedureConfigs <Employee>(); dbProvider.SetQuery(storedProcedureConfigs._INSERT_SINGLE_STORED_PROCEDURE, CommandType.StoredProcedure) .SetParameter("Name", SqlDbType.NVarChar, employee.Name, ParameterDirection.Input) .SetParameter("Dob", SqlDbType.DateTime, employee.Dob, ParameterDirection.Input) .SetParameter("Gender", SqlDbType.Int, employee.Gender, ParameterDirection.Input) .SetParameter("PhoneNumber", SqlDbType.Int, employee.PhoneNumber, ParameterDirection.Input) .SetParameter("FK_ComputerRoomId", SqlDbType.Int, employee.FK_ComputerRoomId, ParameterDirection.Input) .SetParameter("FK_ProvinceId", SqlDbType.Int, employee.FK_ProvinceId, ParameterDirection.Input) .SetParameter("Status", SqlDbType.Int, employee.Status, ParameterDirection.Input) .SetParameter("CreatedBy", SqlDbType.NVarChar, employee.CreatedBy, ParameterDirection.Input) .SetParameter("ERROR_CODE", SqlDbType.NVarChar, DBNull.Value, 100, ParameterDirection.Output) .SetParameter("ERROR_MESSAGE", SqlDbType.NVarChar, DBNull.Value, 400, ParameterDirection.Output) .ExcuteNonQuery() .Complete(); dbProvider.GetOutValue("ERROR_CODE", out outCode) .GetOutValue("ERROR_MESSAGE", out outMessage); return(new ReturnResult <Employee>() { ErrorCode = outCode, ErrorMessage = outMessage, }); }
public async Task <IActionResult> AddEmployee(AddEmployeeModel model) { if (ModelState.IsValid) { var token = HttpContext.Session.GetString("token"); var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var stringContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"); var result = await client.PostAsync($"{_config["BaseApiUrl"]}api/Employees/add", stringContent); if (result.IsSuccessStatusCode) { return(RedirectToAction(nameof(Index))); } } ModelState.AddModelError(string.Empty, "invalid attempt"); var positions = await GetPositionsAsync(); model.Positions = positions.EntityToSelectListItems(); return(View(model)); }
public AddEmployeeViewModel() { Model = new AddEmployeeModel(); Model.DateOfBirth = DateTime.Now; Model.GenderCollection = Enum.GetValues(typeof(Genders)).Cast <Genders>().ToList(); Model.Gender = Genders.Male; }
public ActionResult AddEmployee(AddEmployeeModel employee) { if (ModelState.IsValid) { //clalling BLL function EmployeeLogic.addEmployee(employee); } return(View()); }
public async Task <ActionResult> Add(AddEmployeeModel Employee) { Employee.CreatedBy = _userSessionHelper.GetUserSession().UserName; string apiUrl = _appUrlHelper.GetApiUrl(ApiUrlPath.EMPLOYEE_ADD); var result = await HttpUtilities.PostAsyncApi <ReturnResult <Employee> >(apiUrl, JsonConvert.SerializeObject(Employee)); return(Json(result)); }
public async Task <ServiceResponseModel <Employee> > AddEmployeeAsync(AddEmployeeModel addEmployee) { var newEmployee = await _employeeRepository.AddEmployeeAsync(addEmployee); var addNewEmployeeStatus = newEmployee.Id > 0 ? ServiceStatusCode.Success : ServiceStatusCode.Error; return(ServiceResponseUtil.GetServiceResponse(addNewEmployeeStatus, newEmployee)); }
public ActionResult AddEmployee() { AddEmployeeModel addEmployeeModel = new AddEmployeeModel { Department = _deptService.GetDepartments() }; return(View(addEmployeeModel)); }
public async Task AddEmployeesAsync(AddEmployeeModel newEmployee) { var response = await _client.PostAsJsonAsync("api/EmployeeBenefits/AddEmployee", newEmployee); if (!response.IsSuccessStatusCode) { //todo: log errors } }
public async Task <IActionResult> AddEmployee(AddEmployeeModel model) { if (!ModelState.IsValid) { return(View(model)); } await _employees.Add(model.FirstName, model.LastName, model.Title); return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> AddEmployee() { var positions = await GetPositionsAsync(); var employee = new AddEmployeeModel { Positions = positions.EntityToSelectListItems() }; return(View(employee)); }
public ActionResult AddEmployee() { DatabaseInterface db = new DatabaseInterface(); AddEmployeeModel model = new AddEmployeeModel() { AvailableRoutes = db.GetAvailableRoutes(), StateNames = stateNames, StateAbbreviations = stateAbbreviations }; return(PartialView("AddEmployee", model)); }
public ActionResult AddEmployee(AddEmployeeModel aem) { if (ModelState.IsValid) { _empService.AddEmployee(aem); return(RedirectToAction("DisplayEmployees", "Employee")); } else { return(View(aem)); } }
public async Task <IActionResult> AddEmployee(AddEmployeeModel employee) { try { await new EmployeeTransactions().AddEmployee(_addEmployeeCommand, employee).ConfigureAwait(false); } catch (Exception ex) { return(BadRequest(ex.InnerException)); } return(Ok()); }
private void GetEmployeeDetails(AddEmployeeModel addEmployeeModel) { List <Employee_Details> employeeDetailsList = EmployeeManager.GetEmployeeDetails(); addEmployeeModel.EmployeeDetailsList = employeeDetailsList.Select(i => new EmployeeDetailsList { EmpId = i.EmployeeId, KnownAs = i.KnownAs, FirstName = i.EmployeeFirstName, LastName = i.EmployeeLastName, JoinedDate = i.JoinDate.ToString() }).OrderByDescending(i => i.FirstName).ToList(); }
public void AddEmployee(AddEmployeeModel aem) { var dept = _repo.GetById(aem.DepartmentId.ID); Employee employee = new Employee(); employee.Department = dept; employee.Name = aem.EmployeeName; employee.DateOfJoining = aem.DateOfJoining; employee.Age = aem.Age; employee.Salary = aem.Salary; employee.Comm = aem.Comm; _repo.AddEmployee(employee); }
public async Task <IActionResult> AddEmployee(AddEmployeeModel employee) { try { await new EmployeeOrchestration().AddEmployeeAsync(_employeeRepository, employee).ConfigureAwait(false); } catch (Exception ex) { return(BadRequest(ex.InnerException)); } return(Ok()); }
public ActionResult SaveEmployeeDetails(AddEmployeeModel addEmployeeModel) { EmployeeManager.SaveEmployeeDetails( addEmployeeModel.EmployeeId, addEmployeeModel.FirstName, addEmployeeModel.LastName, addEmployeeModel.KnownAs, addEmployeeModel.JoinedDate ); return(RedirectToAction("AddEmployee", new LeaveDashboardModel { IsRedirectedAfterSave = true, OpperationMessage = "The changes were successfully saved." })); }
public ActionResult AddEmployee([FromBody] AddEmployeeModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = _employeeService.AddEmployee(model); return(Ok(result)); } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }
public async Task AddEmployeesAsync(AddEmployeeModel newEmployee) { try { var response = await _client.PostAsJsonAsync("api/Employee/AddEmployee", newEmployee); if (response.IsSuccessStatusCode) { } else { } } catch (Exception ex) { // add log throw; } }
public ActionResult AddEmployee(AddEmployeeModel model) { if (ModelState.IsValid) { _companyService.AddEmploee(model.CompanyId, new Employee() { Email = model.Email, FirstName = model.Name, LastName = model.LastName, Password = model.Password, Id = Guid.NewGuid() }); return(RedirectToAction("IndexPage", new { id = model.CompanyId })); } else { return(RedirectToAction("AddEmployee", new { id = model.CompanyId })); } }
public void addEmployee(AddEmployeeModel employee) { if (Sqlcon.State == ConnectionState.Closed) { Sqlcon.Open(); SqlCommand Sqlcmd = new SqlCommand("SP_Add_Employee", Sqlcon); Sqlcmd.CommandType = CommandType.StoredProcedure; Sqlcmd.Parameters.AddWithValue("@EmpName", employee.EmpName); Sqlcmd.Parameters.AddWithValue("@EmpAddress", employee.EmpAddress); Sqlcmd.Parameters.AddWithValue("@EmpContact", employee.EmpContact); Sqlcmd.Parameters.AddWithValue("@EmpEmail", employee.EmpEmail); Sqlcmd.Parameters.AddWithValue("@EmpCNIC", employee.EmpCNIC); Sqlcmd.Parameters.AddWithValue("@EmpDOB", employee.EmpDOB); Sqlcmd.Parameters.AddWithValue("@EmpDepartment", employee.EmpDepartment); Sqlcmd.Parameters.AddWithValue("@EmpDesignation", employee.EmpDesignation); Sqlcmd.Parameters.AddWithValue("@EmpRating", employee.EmpRating); Sqlcmd.ExecuteNonQuery(); Sqlcon.Close(); } }
public ActionResult AddEmployee(AddEmployeeModel model) { // check if any of the dependents are not containign a first or last name. if (model.Dependents != null && model.Dependents.Any(x => string.IsNullOrEmpty(x.DependentFirstName) || string.IsNullOrEmpty(x.DependentLastName))) { ModelState.AddModelError("", "Depedents First and Last name are required."); } if (ModelState.IsValid) { Employee employee = new Employee { FirstName = model.FirstName, LastName = model.LastName, StateId = model.StateId.Value, Email = model.Email, AnnualSalary = model.AnnualSalary }; if (model.Dependents != null && model.Dependents.Any()) { foreach (var dependent in model.Dependents) { employee.Dependents.Add(new Dependent { FirstName = dependent.DependentFirstName, LastName = dependent.DependentLastName }); } } employee = EmployeeRepository.Create(employee); return(Json(new PostResultModel { IsSuccess = true, Message = "Employee Added", Html = PartialView("EmployeeRow", new EmployeeRowModel(employee)).RenderToString() })); } model.Populate(StateRepository.GetAll(), BenefitSettingsRepository.GetPublic()); return(PartialView(model)); }
public ReturnResult <Employee> AddEmployee(AddEmployeeModel employee) { return(EmployeeDAL.Add(employee)); }
public async Task AddEmployee(IAddCommandNoResult <EmployeeEntity> addEmployeeCommand, AddEmployeeModel employeeModel) { // todo: apply error checking before executing command var now = DateTime.Now; var employee = new EmployeeEntity(); employee.FirstName = employeeModel.FirstName; employee.LastName = employeeModel.LastName; employee.Id = Guid.NewGuid(); employee.CreatedOn = now; employee.CreatedBy = string.Empty; employee.UpdatedOn = now; employee.UpdatedBy = string.Empty; employee.Salary = new List <EmployeeSalary> { new EmployeeSalary() { YearlyWages = 2000 * 26, StartDate = DateTime.Now, EndDate = null, CreatedOn = now, CreatedBy = string.Empty, UpdatedOn = now, UpdatedBy = string.Empty } }; await addEmployeeCommand.ExecuteAsync(employee); }
//add record public void addEmployee(AddEmployeeModel employee) { EmployeeDAL.addEmployee(employee); }
public string AddNewEmployee(AddEmployeeModel model) { throw new NotImplementedException(); }
public ResponseModel AddEmployee(AddEmployeeModel model) { var resp = new ResponseModel(); try { var validateEmployee = new AddEmployeeModelValidator().Validate(model); if (validateEmployee.IsValid) { // verificar se a empresa existe no sistema. var company = _companyRepository.GetById(Guid.Parse(model.CompanyId)); if (company != null) { var userModel = new AddUserModel { Name = model.Name, Email = model.Email, Password = model.Password, Locations = model.Locations, PhoneNumbers = model.PhoneNumbers, Imagem = model.Imagem }; List <Roles> roles = new List <Roles>(); roles.Add(Roles.Funcionario); var userResponse = _userService.CreateUserFromModel(userModel, roles); if (userResponse.Success) { User newUser = userResponse.Result as User; Employee employee = new Employee { EmployeeId = Guid.NewGuid(), CompanyId = company.CompanyId, IsManager = model.IsManager, Descricao = model.Descricao, CPF = model.CPF, RG = model.RG, CreatedAt = DateTimeUtil.UtcToBrasilia(), LastUpdatedAt = DateTimeUtil.UtcToBrasilia(), UserId = newUser.UserId, User = newUser, }; _employeeRepository.Add(employee); ResponseModel send = _userService.SendEmailConfirmation(userModel.Email).Result; resp.Success = true; resp.Result = $"{employee.EmployeeId}"; resp.Message = "Funcionário adicionado com sucesso!"; } else { resp = userResponse; } } else { resp.Message = "Empresa não encontrada no banco de dados"; } } else { resp.Message = validateEmployee.Errors.FirstOrDefault().ErrorMessage; } } catch (Exception e) { resp.Message = "Não foi possível adicionar o funcionário"; } return(resp); }
public async Task <ServiceResponseModel <Employee> > AddEmployee(AddEmployeeModel addEmployeeModel) { return(await _employeeService.AddEmployeeAsync(addEmployeeModel)); }