Exemple #1
0
        public ActionResult Create_Post()
        {
            EmployeeVO objEmployee = new EmployeeVO();

            TryUpdateModel(objEmployee);

            if (ModelState.IsValid)
            {
                objEmployee.CreatedByID = 1;
                objEmployee.CreatedOn   = DateTime.Now;
                objEmpBO.AddEmployee(objEmployee);
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Exemple #2
0
        public ActionResult CreateEmployee(tbl_MCE_Employee mce_Employee)
        {
            mce_Employee.vchPassword = Util.GetHashByte("password");
            _employee.AddEmployee(mce_Employee);
            ModelState.Clear();

            var gender = new List <DDL_Data> {
                new DDL_Data()
                {
                    vchText = "Male", vchValue = "Male"
                },
                new DDL_Data()
                {
                    vchText = "Female", vchValue = "Female"
                },
                new DDL_Data()
                {
                    vchText = "prefer not to say", vchValue = "prefer not to say"
                }
            };

            ViewBag.gender     = gender.ToList();
            ViewBag.courseList = _course.CourseList1().ToList();
            //ViewBag.branchList = _branches.BranchList().ToList();
            ViewBag.designationList  = _designation.DesignationList().ToList();
            ViewBag.joinCategoryList = _joincategory.JoinCategoryList().ToList();
            ViewBag.roleList         = _role.RoleList().ToList();
            ViewBag.levelList        = _level.LevelList().ToList();
            ViewBag.employeeList     = _employee.EmployeeList1().ToList();
            TempData["Success"]      = "Data Created Successfully";
            return(View());
        }
 public IActionResult Create(EmployeeCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         string uniqueFileName = null;
         if (model.Photo != null)
         {
             string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images");
             uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Photo.FileName;
             string filePath = Path.Combine(uploadsFolder, uniqueFileName);
             model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
         }
         Employee newEmployee = new Employee
         {//C:\codebits-academy\ASPDotNet\CodeBitsAcademyEFC\CodeBitsAcademyEFC\wwwroot\images\2018-07-08-08-46-18-717 - Copy.jpg
             FirstName   = model.FirstName,
             LastName    = model.LastName,
             Age         = model.Age,
             Gender      = model.Gender,
             Email       = model.Email,
             HomeAddress = model.HomeAddress,
             PhoneNumber = model.PhoneNumber,
             PhotoPath   = uniqueFileName
         };
         _employee.AddEmployee(newEmployee);
         // _employee.AddEmployee(employee);
         return(RedirectToAction(nameof(Create)));
     }
     else
     {
         return(View());
     }
 }
Exemple #4
0
        //FOR IN-MEMORY
        //public IActionResult Createview(MEmployee employee)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        MEmployee newemployee = _emp_repository.AddEmployee(employee);
        //        return RedirectToAction("detailsview", new { id = newemployee.EmpID });
        //    }
        //    return View();
        //}

        //FOR SQL
        public IActionResult Createview(EmployeeCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniquefilename = null;
                if (model.Photo != null)
                {
                    string uploadFolderPath = ProcessUploadedFile(model);
                    uniquefilename = uploadFolderPath;
                    //string uploadFolderPath = Path.Combine(_hostEnvironment.WebRootPath, "uploads");
                    //uniquefilename = Guid.NewGuid().ToString() + "-" + model.Photo.FileName;
                    //string filepath = Path.Combine(uploadFolderPath, uniquefilename);
                    //model.Photo.CopyTo(new FileStream(filepath, FileMode.Create));
                }

                MEmployee newemployee = new MEmployee
                {
                    Name      = model.Name,
                    Email     = model.Email,
                    Dept      = model.Dept,
                    PhotoPath = uniquefilename
                };

                _emp_repository.AddEmployee(newemployee);

                return(RedirectToAction("detailsview", new { id = newemployee.EmpID }));
            }
            return(View());
        }
 public void Create([FromBody] Employee employee)
 {
     if (ModelState.IsValid)
     {
         objemployee.AddEmployee(employee);
     }
 }
 public IActionResult  Create(EmployeeViewModel model)
 {
     ViewBag.Departments = new SelectList(_department.AllDepartments, "ID", "Name");
     if (ModelState.IsValid)
     {
         string uniqueFileName = null;
         if (model.Photo != null)
         {
             string uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "images");
             uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Photo.FileName;
             string filePath = Path.Combine(uploadsFolder, uniqueFileName);
             model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
         }
         Employee employees = new Employee()
         {
             //Id = model.Id,
             FirstName   = model.FirstName,
             LastName    = model.LastName,
             Age         = model.Age,
             PhoneNumber = model.PhoneNumber,
             Email       = model.Email,
             Gender      = model.Gender,
             Address     = model.Address,
             PhotoPath   = uniqueFileName
         };
         _employee.AddEmployee(employees);
         return(View("SuccessMessage", employees));
     }
     else
     {
         return(View());
     }
 }
        public IHttpActionResult AddEmployee(Employee employee)
        {
            _employee.AddEmployee(employee);


            //sending mail while creating user
            Common.BAL.SendMail(employee.EmailId, "*****@*****.**", "Employee Registration", "Welcome to our company");
            return(Ok(new { message = "Employee is added successfully." }));
        }
Exemple #8
0
 public IActionResult PostEmployee(Employee employee)
 {
     using (var scope = new TransactionScope())
     {
         employee1.AddEmployee(employee);
         scope.Complete();
         CreatedAtAction(nameof(GetEmployee), new { id = employee.EmpId }, employee);
         return(Ok());
     }
 }
        public EmpMaster AddEmployee(EmpMaster employee)
        {
            if (employee == null || employee.Name == null)
            {
                return(null);
            }
            var empResultSet = _employee.AddEmployee(employee);

            return(empResultSet);
        }
Exemple #10
0
 public async Task <IActionResult> AddAsync([FromBody] Employee employee)
 {
     try
     {
         return(StatusCode(200, await _repo.AddEmployee(employee)));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         _logger.LogError(ex.StackTrace);
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
Exemple #11
0
        public ActionResult Create([Bind(Include = " First_Name,Last_Name,Email,Password,Gender,Designation ,Description,Joined_date")] EmployeeModel employee, HttpPostedFileBase file)
        {
            int retvalue = _IEmployee.AddEmployee(employee, file);

            if (retvalue > 0)
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.genderList = new SelectList(new List <string>()
            {
                "Male", "Female"
            });
            return(View(employee));
        }
Exemple #12
0
 public IActionResult CreateEmployee([FromBody] EmployeeViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Not a valid model"));
     }
     try
     {
         return(_context.AddEmployee(_mapper.Map <Employee>(model)) ? Ok() : StatusCode(StatusCodes.Status304NotModified));
     }
     catch (Exception ex)
     {
         _logger.LogDebug(ex, ex.Message);
     }
     return(StatusCode(StatusCodes.Status500InternalServerError));
 }
Exemple #13
0
        public IActionResult Create(EmployeeCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                string UniqueFileName = null;
                //if (model.Photo != null&&model.Photos.Count > 0)
                //{
                //    foreach (IFormFile Photo in model.Photos)
                //    {
                //        string UploadsFolder = Path.Combine(_webHostEnvironment.WebRootPath, "images");
                //        UniqueFileName = Guid.NewGuid().ToString() + "_" + Photo.FileName;
                //        string filePath = Path.Combine(UploadsFolder, UniqueFileName);
                //        Photo.CopyTo(new FileStream(filePath, FileMode.Create));

                //    }
                //}

                if (model.Photo != null)
                {
                    string UploadsFolder = Path.Combine(_webHostEnvironment.WebRootPath, "images");
                    //UniqueFileName = Path.Combine(Guid.NewGuid().ToString(), "_", model.Photo.FileName);
                    UniqueFileName = Guid.NewGuid().ToString() + "_" + model.Photo.FileName;
                    string filePath = Path.Combine(UploadsFolder, UniqueFileName);
                    model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
                }

                Employee emp = new Employee
                {
                    FirstName    = model.FirstName,
                    LastName     = model.LastName,
                    DepartmentId = model.DepartmentId,
                    Email        = model.Email,
                    PhotoPath    = UniqueFileName
                };
                //_employeerepository.AddEmployee(employee);
                _employeerepository.AddEmployee(emp);

                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.Depts = new SelectList(_departmentrepository.GetDepartments(), "DepartmentId", "DepartmentName", model.DepartmentId);

            return(View(model));
        }
Exemple #14
0
        private static void EnterEmployee(IEmployee employee)
        {
            var employeeType = employee.GetType().Name;

            while (true)
            {
                Console.WriteLine($"ENTER A {employeeType}  ('Name', 'Salary') or 'q' to quit");

                var input = Console.ReadLine();

                if (input == "q")
                {
                    break;
                }

                try
                {
                    var employeeValues = input.Split(',', StringSplitOptions.RemoveEmptyEntries);
                    if (employeeValues.Length < 0 || employeeValues.Length > 2)
                    {
                        Console.WriteLine("Enter a employee ('Name', 'Salary')");
                    }

                    employee.AddEmployee(new EmployeeDTO {
                        Name = employeeValues[0], Salary = double.Parse(employeeValues[1])
                    });
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (FormatException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    Console.WriteLine("");
                }
            }
        }
Exemple #15
0
        public async Task <ActionResult <Employee> > CreateEmployee(Employee emp)
        {
            try
            {
                if (emp == null)
                {
                    return(BadRequest());
                }
                var employee = _employeeRepository.GetEmployeeByEmail(emp.Email);
                if (employee != null)
                {
                    ModelState.AddModelError("Email", "This Email Already Exists");
                    return(BadRequest(ModelState));
                }
                var Created = await _employeeRepository.AddEmployee(emp);

                return(CreatedAtAction(nameof(GetEmployee), new { id = Created.EmployeeId }, Created));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error From DB"));
            }
        }
 public int Create([FromBody] TblEmployee employee)
 {
     return(objemployee.AddEmployee(employee));
 }
Exemple #17
0
 public int Create([FromBody] Employee employee)
 {
     return(_objEmployee.AddEmployee(employee));
 }
 public void Post([FromBody] Employee employee)
 {
     _employeeRepository.AddEmployee(employee);
 }
Exemple #19
0
 public void Post([FromBody] Employee employee)
 {
     objemployee.AddEmployee(employee);
 }
Exemple #20
0
 public IActionResult AddEmployee(Employee employee)
 {
     _tem.AddEmployee(employee);
     return(RedirectToAction(nameof(List)));
 }
 public int Create([FromBody] TblEmployee employee)
 {
     return(employeeDataAccess.AddEmployee(employee));
 }
Exemple #22
0
 public void Create(Employee employee)
 {
     objemployee.AddEmployee(employee);
 }
Exemple #23
0
 public void AddEmployee(EmployeeDTO employee)
 {
     _employeeContext.AddEmployee(employee);
 }
Exemple #24
0
 public IActionResult Post(Employee employee)
 {
     objemployee.AddEmployee(employee);
     return(Ok());
 }
Exemple #25
0
 public int Create([FromBody] ModelEmployees employee)
 {
     return(_emp.AddEmployee(employee));
 }
Exemple #26
0
 public void Post(Employee employee)
 {
     _employeeService.AddEmployee(employee);
 }
Exemple #27
0
 public void Create([FromBody] Tbemployee emp)
 {
     _emp.AddEmployee(emp);
 }