Пример #1
0
        public int AddEmployee(Employee emp)
        {
            GetEmail checkemail = new GetEmail();

            checkemail.Email = emp.EmpEmail;

            try
            {
                if (this.IsEmailUnique(checkemail) == false)
                {
                    Random rand          = new Random((int)DateTime.Now.Ticks);
                    int    numIterations = rand.Next(10000, 99999);

                    DateTime today = DateTime.Today;
                    emp.StartDate    = today;
                    emp.RegisterCode = numIterations.ToString();
                    emp.PositionPId  = "RC";
                    _context.Employees.Add(emp);
                    _context.SaveChanges();

                    return(numIterations);
                }
                return(0);
            }
            catch
            {
                return(0);
            }
        }
Пример #2
0
        /// <summary>
        /// if forgot password genarate new register code
        /// </summary>
        /// <param name="email"></param>
        /// <returns> register code</returns>
        public int ForgetPassword(string email)
        {
            try
            {
                GetEmail getEmail = new GetEmail();
                getEmail.Email = email;
                if (this.IsEmail(getEmail) == true)
                {
                    Random rand        = new Random((int)DateTime.Now.Ticks);
                    int    regitercode = rand.Next(10000, 99999);

                    //  Employee employee = new Employee();
                    // employee = GetEmployeeByEmail(email);
                    Employee employee = _context.Employees.Where(c => c.IsActive == true && c.EmpEmail == email).FirstOrDefault();
                    employee.RegisterCode          = regitercode.ToString();
                    _context.Entry(employee).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    _context.SaveChanges();
                    return(regitercode);
                }
                return(0);
            }
            catch
            {
                return(0);
            }
        }
Пример #3
0
        public Boolean RegisterEmployee(RegisterActive reg)
        {
            try
            {
                GetEmail getEmail = new GetEmail();
                getEmail.Email = reg.RegisterEmpEmail;

                if (this.IsEmailUnique(getEmail) == false)
                {
                    var data = _context.Employees
                               .Where(c => c.EmpEmail == reg.RegisterEmpEmail && c.RegisterCode == reg.RegisterCode)
                               .Select(c => c.EmpEmail)
                               .FirstOrDefault();

                    if (string.IsNullOrEmpty(data))
                    {
                        return(false);
                    }
                    else
                    {
                        var employee = _context.Employees.Where(c => c.EmpEmail == reg.RegisterEmpEmail && c.RegisterCode == reg.RegisterCode).FirstOrDefault();
                        employee.IsActive = true;
                        _context.Entry(employee).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                        _context.SaveChanges();
                        return(true);
                    }
                }
                return(false);
            } catch { return(false); }
        }
Пример #4
0
        /// <summary>
        /// after forgot password update employee new password
        /// </summary>
        /// <param name="getEP"></param>
        /// <returns> if success return true</returns>
        public Boolean SetEmailAndPassword(GetEmailPassword getEP)
        {
            GetEmail getEmail = new GetEmail();

            getEmail.Email = getEP.EmpEmail;

            if (this.IsEmail(getEmail) == true)
            {
                Random   rand          = new Random((int)DateTime.Now.Ticks);
                int      numIterations = rand.Next(10000, 99999);
                Employee employee      = new Employee();
                employee = _context.Employees
                           .Where(c => c.EmpEmail == getEP.EmpEmail && c.IsActive == true).FirstOrDefault();
                if (employee.RegisterCode == getEP.Code)
                {
                    employee.EmpPassword           = getEP.EmpPassword;
                    employee.RegisterCode          = numIterations.ToString();
                    _context.Entry(employee).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    _context.SaveChanges();
                    return(true);
                }
                return(false);
            }
            return(false);
        }
Пример #5
0
        private void envoiEmailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // mailbox recupere le mail et appelle le reste de la fonction (sending_mail)
            GetEmail mailbox = new GetEmail(this);

            mailbox.Show();
        }
 public Boolean IsEmailUnique([FromBody] GetEmail email)
 {
     try
     {
         return(_service.IsEmailUnique(email));
     }
     catch
     {
         return(false);
     }
 }
Пример #7
0
 public IActionResult IsEmailUnique([FromBody] GetEmail email)
 {
     try
     {
         var employee = _service.IsEmailUnique(email);
         return(Ok(employee));
     }
     catch
     {
         return(BadRequest());
     }
 }
Пример #8
0
        //SandEmail ticket, int mode = 0
        protected void SendMail_BCOM(GetEmail Email)
        {
            string fnt1 = "<font size='5' face='Angsana New'>";
            string fnt2 = "</font>";

            //string url = global::System.Configuration.ConfigurationManager.AppSettings["Beauty.Host"].ToString();

            try
            {
                MailMessage mail = new MailMessage();

                mail.From = new MailAddress("*****@*****.**", "User");

                mail.To.Add("*****@*****.**");
                mail.Subject = "Information request from your website";

                //if (devdetail.EMAIL != null && devdetail.EMAIL.Length > 10)
                //{
                //    mail.To.Add(devdetail.EMAIL_CRE);
                //}
                //else{
                //    mail.Subject = "ปิด Ticket ! " + devdetail.TOPIC;
                //}

                mail.IsBodyHtml = true;
                StringBuilder sb = new StringBuilder();


                //url = url + "/Dev/DevDetail?DevId=" + devdetail.DV_ID.ToString();


                sb.Append($"<br><b>{fnt1} มีผู้สมัครงานใหม่ !!{fnt2}</b><hr>");

                sb.Append($"<br><strong>{fnt1}ชื่อ-นามสกุล</strong> : {Email.FULLNAME}{fnt2}"); //ชื่อ-นามสกุล
                sb.Append($"<br><strong>{fnt1}อีเมลติดต่อ</strong> : {Email.EMAIL}{fnt2}");     //อีเมลติดต่อกลับ
                sb.Append($"<br><strong>{fnt1}เบอร์ต่อต่อ</strong> : {Email.PHONE}{fnt2}");     //เบอร์ติดต่อ
                sb.Append($"<br><strong>{fnt1}รายละเอียด</strong> : {Email.MESSAGE}{fnt2}");    //รายละเอียด


                mail.Body = sb.ToString();


                SmtpClient stmp = new SmtpClient();
                stmp.Send(mail);

                ViewBag.ErrorMessage = "Success";
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
            }
        }
Пример #9
0
        public ActionResult SandEmail_S(SandEmail mail)
        {
            GetEmail Email = new GetEmail();

            Email.FULLNAME = mail.FULLNAME;
            Email.EMAIL    = mail.EMAIL;
            Email.PHONE    = mail.PHONE;
            Email.MESSAGE  = mail.MESSAGE;

            SendMail(Email);

            return(RedirectToAction("success", "Home"));
        }
Пример #10
0
        public Boolean IsEmail(GetEmail email)
        {
            var data = _context.Employees
                       .Where(c => c.EmpEmail == email.Email && c.IsActive == true)
                       .Select(c => c.EmpId)
                       .FirstOrDefault();

            if (data != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #11
0
        //SandEmail ticket, int mode = 0
        protected void SendMail(GetEmail Email)
        {
            string fnt1 = "<font size='5' face='Angsana New'>";
            string fnt2 = "</font>";

            //string url = global::System.Configuration.ConfigurationManager.AppSettings["Beauty.Host"].ToString();

            try
            {
                MailMessage mail = new MailMessage();

                mail.From = new MailAddress("*****@*****.**", "International Business");

                mail.To.Add("*****@*****.**");
                mail.Subject = "Inquiry BeautyCommunity";


                mail.IsBodyHtml = true;
                StringBuilder sb = new StringBuilder();


                //url = url + "/Dev/DevDetail?DevId=" + devdetail.DV_ID.ToString();


                sb.Append($"<br><b>{fnt1} มีผู้สมัครงานใหม่ !!{fnt2}</b><hr>");

                sb.Append($"<br><strong>{fnt1}ชื่อ-นามสกุล</strong> : {Email.FULLNAME}{fnt2}"); //ชื่อ-นามสกุล
                sb.Append($"<br><strong>{fnt1}อีเมลติดต่อ</strong> : {Email.EMAIL}{fnt2}");     //อีเมลติดต่อกลับ
                sb.Append($"<br><strong>{fnt1}เบอร์ต่อต่อ</strong> : {Email.PHONE}{fnt2}");     //เบอร์ติดต่อ
                sb.Append($"<br><strong>{fnt1}รายละเอียด</strong> : {Email.MESSAGE}{fnt2}");    //รายละเอียด


                mail.Body = sb.ToString();


                SmtpClient stmp = new SmtpClient();
                stmp.Send(mail);

                ViewBag.ErrorMessage = "Success";
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
            }
        }
Пример #12
0
        /// <summary>
        /// check the email in the database
        /// </summary>
        /// <param name="email"></param>
        /// <returns> true if email in table</returns>
        public ViewEmployee IsEmailUnique(GetEmail email)
        {
            var data = _context.Employees
                       .Where(c => c.EmpEmail == email.Email)
                       .Select(c => c.IsActive)
                       .FirstOrDefault();
            var employee = _context.Employees.Where(c => c.EmpEmail == email.Email).Select(c => new ViewEmployee {
                EmpEmail = c.EmpEmail, EmpName = c.EmpName, EmpProfilePicture = c.EmpProfilePicture
            }).FirstOrDefault();

            if (data)
            {
                return(employee);
            }
            else
            {
                return(employee);
            }
        }
Пример #13
0
        public int ForgetPassword(string email)
        {
            try {
                GetEmail getEmail = new GetEmail();
                getEmail.Email = email;
                if (this.IsEmailUnique(getEmail) == true)
                {
                    Random rand          = new Random((int)DateTime.Now.Ticks);
                    int    numIterations = rand.Next(10000, 99999);

                    Employee employee = new Employee();
                    employee = GetEmployeeByEmail(email);
                    employee.RegisterCode = numIterations.ToString();
                    UpdateEmployee(employee);
                    return(numIterations);
                }
                return(0);
            } catch {
                return(0);
            }
        }
Пример #14
0
        public async Task <ActionResult> AddEmails([FromBody] GetEmail x)
        {
            var applist = await db.Emails.Where(m => m.Application == x.Application).Select(m => m.Application).FirstOrDefaultAsync();

            if (applist != x.Application && x.Application != null)
            {
                db.Emails.Add(new Emails {
                    Application = x.Application,
                    Email_1     = x.Email_1,
                    Email_2     = x.Email_2,
                    Email_3     = x.Email_3,
                    Enable      = x.Enable
                });
                await db.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Пример #15
0
        public Boolean SetEmailAndPassword(GetEmailPassword getEP)
        {
            GetEmail getEmail = new GetEmail();

            getEmail.Email = getEP.EmpEmail;

            if (this.IsEmailUnique(getEmail) == true)
            {
                Random   rand          = new Random((int)DateTime.Now.Ticks);
                int      numIterations = rand.Next(10000, 99999);
                Employee employee      = new Employee();
                employee = GetEmployeeByEmail(getEP.EmpEmail);
                if (employee.RegisterCode == getEP.Code)
                {
                    employee.EmpPassword  = getEP.EmpPassword;
                    employee.RegisterCode = numIterations.ToString();
                    UpdateEmployee(employee);
                    return(true);
                }
                return(false);
            }
            return(false);
        }
Пример #16
0
        /// <summary>
        /// register employee using regiter code
        /// </summary>
        /// <param name="reg"></param>
        /// <returns> if success return true</returns>
        public Boolean RegisterEmployee(RegisterActive reg)
        {
            try
            {
                GetEmail getEmail = new GetEmail();
                getEmail.Email = reg.RegisterEmpEmail;

                if (this.IsEmail(getEmail) == false)
                {
                    var data = _context.Employees
                               .Where(c => c.EmpEmail == reg.RegisterEmpEmail && c.RegisterCode == reg.RegisterCode)
                               .Select(c => c.EmpEmail)
                               .FirstOrDefault();

                    if (string.IsNullOrEmpty(data))
                    {
                        return(false);
                    }
                    else
                    {
                        //create new  random number for register code
                        Random rand        = new Random((int)DateTime.Now.Ticks);
                        int    regitercode = rand.Next(10000, 99999);

                        var employee = _context.Employees.Where(c => c.EmpEmail == reg.RegisterEmpEmail && c.RegisterCode == reg.RegisterCode).FirstOrDefault();
                        employee.IsActive              = true;
                        employee.RegisterCode          = regitercode.ToString();
                        _context.Entry(employee).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                        _context.SaveChanges();
                        return(true);
                    }
                }
                return(false);
            }
            catch { return(false); }
        }
Пример #17
0
        /// <summary>
        ///  login by email
        /// </summary>
        /// <param name="log"></param>
        /// <returns>if login success return true</returns>
        public Boolean LoginEmail(LoginEmail log)
        {
            GetEmail getEmail = new GetEmail();

            getEmail.Email = log.EmpEmail;

            if (this.IsEmail(getEmail))
            {
                var data = _context.Employees
                           .Where(c => c.EmpEmail == log.EmpEmail && c.EmpPassword == log.EmpPassword)
                           .Select(c => c.EmpId)
                           .FirstOrDefault();

                if (string.IsNullOrEmpty(data))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #18
0
        public async Task <ActionResult> UpdateEmail([FromBody] GetEmail Mail)
        {
            var applist = await db.Emails.Where(m => m.Application == Mail.Application).Select(m => m.Application).FirstOrDefaultAsync();

            if (applist == Mail.Application)
            {
                var value = await db.Emails.Where(o => o.Application == Mail.Application).ToListAsync();

                foreach (var data in value)
                {
                    data.Email_1 = Mail.Email_1;
                    data.Email_2 = Mail.Email_2;
                    data.Email_3 = Mail.Email_3;
                    data.Enable  = Mail.Enable;
                }
                await db.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Пример #19
0
        /// <summary>
        /// add a employee to employee table
        /// </summary>
        /// <param name="employee"></param>
        /// <returns>return register code</returns>
        public int AddEmployee(Employee employee)
        {
            GetEmail checkemail = new GetEmail();

            checkemail.Email = employee.EmpEmail;

            try
            {
                if (this.IsEmail(checkemail) == false)
                {
                    //create a random number for register employee
                    Random rand        = new Random((int)DateTime.Now.Ticks);
                    int    regitercode = rand.Next(10000, 99999);

                    //generate today date
                    DateTime today = DateTime.Today;
                    employee.StartDate    = today;
                    employee.LastUpdate   = today;
                    employee.RegisterCode = regitercode.ToString();
                    var count = _context.Employees.Where(c => c.IsActive == true && c.PositionPId == "AD").Count();
                    if (count == 0)
                    {
                        var countAD = _context.Positions.Where(c => c.PositionId == "AD").Count();
                        if (countAD == 0)
                        {
                            Position positionUser = new Position();
                            positionUser.PositionId   = "AD";
                            positionUser.PositionName = "Admin";
                            _context.Positions.Add(positionUser);
                            _context.SaveChanges();
                        }
                        var countuser = _context.Positions.Where(c => c.PositionId == "User").Count();
                        if (countuser == 0)
                        {
                            Position positionUser = new Position();
                            positionUser.PositionId   = "User";
                            positionUser.PositionName = "User";
                            _context.Positions.Add(positionUser);
                            _context.SaveChanges();
                        }
                        var countproject = _context.Projects.Count();
                        if (countproject == 0)
                        {
                            Project project = new Project();
                            project.IsActive    = true;
                            project.ProjectName = "No Project";
                            _context.Projects.Add(project);
                            _context.SaveChanges();
                        }
                        var countdepartment = _context.Departments.Count();
                        if (countdepartment == 0)
                        {
                            Department department = new Department();
                            department.DprtId   = "No";
                            department.DprtName = "No Department";
                            _context.Departments.Add(department);
                            _context.SaveChanges();
                        }

                        employee.DepartmentDprtId = "No";
                        employee.ProjectPrId      = 1;
                        employee.PositionPId      = "AD";
                    }
                    else
                    {
                        if (employee.ProjectPrId == null)
                        {
                            employee.ProjectPrId = 1;
                        }
                        if (employee.DepartmentDprtId == null)
                        {
                            employee.DepartmentDprtId = "No";
                        }
                        employee.PositionPId = "User";
                    }

                    _context.Employees.Add(employee);
                    _context.SaveChanges();
                    //return register code after signup
                    return(regitercode);
                }
                //if did not unique email return 0
                return(0);
            }
            catch
            {
                return(0);
            }
        }
 public Boolean IsEmailUnique(GetEmail email)
 {
     return(_service.IsEmailUnique(email));
 }
 public ViewEmployee IsEmailUnique(GetEmail email)
 {
     return(_service.IsEmailUnique(email));
 }