public async Task <IActionResult> CreateValidation(NewEmpModel newEmp)
        {
            BuildEmp(newEmp);
            await _employeeService.Create(newEmp);

            return(RedirectToAction("Index", "Employees"));
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var emp = new Employee();

            emp.Name   = txtName.Text;
            emp.Inital = txtInital.Text;

            _employeeRepository.Create(emp);
            LoadEmployee();
        }
Beispiel #3
0
 public Employee Create(Employee item)
 {
     try
     {
         return(conn.Create(item));
     }
     catch (Exception)
     {
         return(new Employee());
     }
 }
Beispiel #4
0
        public IHttpActionResult CreateEmployee(EmployeeRegistrationModel json)
        {
            if (json == null || json.CompanyId == 0)
            {
                return(Ok(new { Success = false, Message = "Please create a company from setting menu." }));
            }
            var model = new EmployeeRegistrationModel
            {
                Email              = json.Email,
                PhoneNumber        = json.PhoneNumber,
                Password           = json.Password,
                UserName           = json.UserName,
                Gender             = json.Gender,
                UserFullName       = json.UserFullName,
                UserType           = json.UserType,
                Designation        = json.Designation,
                DepartmentId       = json.DepartmentId,
                CompanyId          = json.CompanyId,
                IsAutoCheckPoint   = json.IsAutoCheckPoint,
                AutoCheckPointTime = json.AutoCheckPointTime,
                MaximumOfficeHours = json.MaximumOfficeHours,
                OfficeOutTime      = json.OfficeOutTime
            };

            var response = CreateUser(model);

            if (!response.Success)
            {
                return(Ok(response));
            }
            EmployeeUser empUser = new EmployeeUser
            {
                UserId             = response.ReturnCode,
                UserName           = model.UserFullName,
                PhoneNumber        = model.PhoneNumber,
                Designation        = model.Designation,
                DepartmentId       = Convert.ToInt32(model.DepartmentId),
                CompanyId          = model.CompanyId,
                IsAutoCheckPoint   = model.IsAutoCheckPoint,
                AutoCheckPointTime = model.AutoCheckPointTime,
                MaximumOfficeHours = model.MaximumOfficeHours,
                OfficeOutTime      = model.OfficeOutTime
            };
            var userResponse = _employeeRepository.Create(empUser);

            return(Ok(new { Success = true, Message = response.Message }));
        }
        public async Task <IActionResult> Create(Employee employee, IList <IFormFile> EmployeeFiles)
        {
            if (!ModelState.IsValid)
            {
                return(View(employee));
            }

            _Employee.Create(employee);

            // Write files to the hosting
            if (EmployeeFiles.Count != 0)
            {
                var UploadsDirectory = Path.Combine(_hostingEnvironment.ContentRootPath, "EmployeeFiles");

                foreach (var item in EmployeeFiles)
                {
                    Files newFile;

                    if (item.Length > 0)
                    {
                        var FilePath = Path.Combine(UploadsDirectory, item.FileName.Replace(" ", "").Replace("-", "_"));
                        using (var FileWritter = new FileStream(FilePath, FileMode.Create))
                        {
                            await item.CopyToAsync(FileWritter);

                            newFile = new Files();
                            // Note : the business logic doing in the files repository not here and Here we just pass the values to the repository
                            newFile.FileName      = item.FileName;
                            newFile.Description   = FilePath;
                            newFile.FileExtension = Path.GetExtension(item.FileName);
                            newFile.EmployeeID    = employee.Id;
                            newFile.OwnerType     = OwnerTypes.Empolyee;
                            _File.Create(newFile);
                        }
                    }
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <ActionResult> AddEmployee(Employee empl, string id)
        {
            try
            {
                var us = _repositoryUser.Get(id);
                _repositoryEmployee.Create(empl);

                IdentityMessage message = new IdentityMessage();
                message.Body        = string.Format(us.NickName + " добавил Вас в свою команду!");
                message.Destination = empl.Email;
                message.Subject     = "Dream team";
                EmailService em = new EmailService();
                await em.SendAsync(message);

                _repositoryUser_Employee.Create(us, empl);
                return(RedirectToAction("GetEmployee", new { id = id }));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #7
0
    public async Task <HttpResponseMessage> Create(EmployeeModel Employee)
    {
        var returnStatus = await _employeeRepositary.Create(Employee);

        return(Request.CreateResponse(HttpStatusCode.OK, returnStatus));
    }
Beispiel #8
0
 public void CreateEmployee(Employee employee)
 {
     Employee emp = iemployee.Create(employee);
 }
Beispiel #9
0
 public ActionResult Create(EmployeeModel model)
 {
     _employee.Create(model);
     return(RedirectToAction("Index"));
 }
Beispiel #10
0
 public void AddEmployee([FromBody] Employee employee) => _employeeRepo.Create(employee);