Beispiel #1
0
        public IActionResult Create([FromForm] GetEmployee emp)
        {
            try
            {
                string res = "";
                if (emp.EmpProfilePicture != null)
                {
                    // add profile picture
                    res = AddFiles.AddImage(emp.EmpProfilePicture, emp.EmpId);
                }
                Hash hash = new Hash();
                emp.EmpPassword = hash.HashPassword(emp.EmpPassword);

                Employee employee = new Employee();
                employee.EmpId             = emp.EmpId;
                employee.EmpEmail          = emp.EmpEmail;
                employee.EmpPassword       = emp.EmpPassword;
                employee.EmpName           = emp.EmpName;
                employee.EmpContact        = emp.EmpContact;
                employee.EmpAddress1       = emp.EmpAddress1;
                employee.EmpAddress2       = emp.EmpAddress2;
                employee.EmpGender         = emp.EmpGender;
                employee.PositionPId       = emp.PositionPId;
                employee.DepartmentDprtId  = emp.DepartmentDprtId;
                employee.EmpProfilePicture = res;
                employee.ProjectPrId       = emp.ProjectId;

                int regitercode = _service.AddEmployee(employee);


                if (regitercode > 0)
                {
                    // if there register code send it bt email
                    Boolean SendCode = SendMail.SendloginCode(regitercode.ToString(), emp.EmpEmail, emp.EmpName);

                    return(Ok(emp));
                }
                else
                {
                    return(BadRequest("there error"));
                }
            }
            catch
            {
                return(BadRequest());
            }
        }
Beispiel #2
0
        public IActionResult UpdateEmployee([FromForm] GetEmployee emp)
        {
            string res = "";

            if (emp.EmpProfilePicture != null)
            {
                // if there profile picture change it
                res = AddFiles.AddImage(emp.EmpProfilePicture, emp.EmpId);
            }
            Hash hash = new Hash();

            emp.EmpPassword = hash.HashPassword(emp.EmpPassword);

            Employee employee = new Employee();

            employee.EmpId             = emp.EmpId;
            employee.EmpEmail          = emp.EmpEmail;
            employee.EmpPassword       = emp.EmpPassword;
            employee.EmpName           = emp.EmpName;
            employee.EmpContact        = emp.EmpContact;
            employee.EmpAddress1       = emp.EmpAddress1;
            employee.EmpAddress2       = emp.EmpAddress2;
            employee.EmpGender         = emp.EmpGender;
            employee.PositionPId       = emp.PositionPId;
            employee.DepartmentDprtId  = emp.DepartmentDprtId;
            employee.EmpProfilePicture = res;
            employee.IsActive          = emp.IsActive;
            employee.StartDate         = emp.StartDate;
            employee.ProjectPrId       = emp.ProjectId;

            if (_service.UpdateEmployee(employee) == 1)
            {
                return(Ok("Changes success full!"));
            }
            if (_service.UpdateEmployee(employee) == 2)
            {
                return(BadRequest("Password not match, Try again."));
            }
            else
            {
                return(BadRequest("there are error"));
            }
        }