Пример #1
0
        public IActionResult HRDirectorCreation(HRDirectorCreationVM data)
        {
            var         compId = compRep.GetCompanyId(data.CompanyName);
            Op_Employee emp    = new Op_Employee();

            emp.Name             = data.Name;
            emp.PhoneNumber      = "0000";
            emp.Email            = data.Email;
            emp.Address          = "0000";
            emp.UniversityName   = "0000";
            emp.UniversityMajor  = "0000";
            emp.GraduationYear   = 0;
            emp.LinkedInAccount  = "0000";
            emp.CompanyId        = compId;
            emp.DepartmentName   = "HR";
            emp.EmployeePosition = "HR Director";
            emp.HiringDate       = DateTime.Today;
            emp.EmployeeStatusId = 1;
            emp.Comment          = "0000";
            emp.EmployeeTypeId   = 2;

            empRep.AddEmployee(emp);
            emp = empRep.GetEmployee(data.Email, data.Email, data.Email);
            Op_EmployeeLoginData eld = new Op_EmployeeLoginData();

            eld.Id               = emp.Id;
            eld.LoginEmail       = emp.Email;
            eld.EmployeePassword = data.Password;
            eldRep.AddEmployeeLoginData(eld);

            return(RedirectToAction("index", "admin"));
        }
Пример #2
0
        public async Task <ActionResult <Employee> > CreateEmployee(Employee employee)
        {
            try
            {
                if (employee == null)
                {
                    return(BadRequest());
                }
                var empEmail = await employeeRepo.GetEmployeeByEmail(employee.Email);

                //var empFirstName = employeeRepo.GetEmployeeByUserName(employee.FirstName);
                //if(empFirstName != null)
                //{
                //    ModelState.AddModelError("FirstName", "First name is used");
                //}
                if (empEmail != null)
                {
                    ModelState.AddModelError("Email", "Email Already in use");
                    return(BadRequest(ModelState));
                }

                var result = await employeeRepo.AddEmployee(employee);

                return(CreatedAtAction(nameof(GetEmployee), new { id = result.EmployeeId }, result));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data"));
            }
        }
Пример #3
0
        public async Task <IActionResult> AddEmployee(string employee)
        {
            var newEmployee = JsonConvert.DeserializeObject <EmployeeBase>(employee);

            if (newEmployee != null)
            {
                await Task.FromResult(_repo.AddEmployee(newEmployee));
            }

            return(Ok());
        }
 //To Add new Employee record
 public async Task AddEmployee(EmployeeModel Employee)
 {
     try
     {
         await _iEmployeeRepo.AddEmployee(Employee);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
 public IActionResult AddEmployee(Employee emp)
 {
     if (ModelState.IsValid)
     {
         if (emp.EmpId == 0)
         {
             employeeRepo.AddEmployee(emp);
         }
         else
         {
             employeeRepo.UpdateEmployee(emp);
         }
         return(RedirectToAction("ViewEmployee"));
     }
     return(View());
 }
 public IActionResult Create(EmployeeCreateViewModel employeeCreateViewModel)
 {
     if (ModelState.IsValid)
     {
         string   uniqueFileName = UploadedFileName(employeeCreateViewModel);
         Employee newEmp         = new Employee()
         {
             Name       = employeeCreateViewModel.Name,
             Department = employeeCreateViewModel.Department,
             Email      = employeeCreateViewModel.Email,
             PhotoPath  = uniqueFileName
         };
         _employeeRepo.AddEmployee(newEmp);
         return(RedirectToAction("Details", new { id = newEmp.EmployeeID }));
     }
     return(View());
 }
Пример #7
0
 public IActionResult AddEmployee(Employee Emp)
 {
     return(Ok(iEmployeeRepo.AddEmployee(Emp)));
 }
Пример #8
0
 public ActionResult AddEmployee([FromBody] Employee emp)
 {
     _employeeRepo.AddEmployee(emp);
     return(Ok(emp));
 }
Пример #9
0
 public void AddEmployee(Employee employee)
 {
     repo.AddEmployee(employee);
 }
Пример #10
0
 public Employee AddEmployee(Employee employee)
 {
     return(_IemployeeRepo.AddEmployee(employee));
 }