public IActionResult ForGot_Pass(string username)
        {
            Users user = _repository.Users.FindByUserName(username);

            if (user == null)
            {
                return(BadRequest());
            }
            string password = EmailManager.CreateRandomPassword(8);
            string To       = username;
            string subject  = "Password Reset";
            string body     = "Hello!" + " \n " +
                              "This mail is sent from Aadyam Consultant \n " +
                              "You have requested to reset your login password \n " +
                              "Your password has been reset and the new Password is : " + password + " \n " +
                              "Please change your password on your first login" +
                              " \n " + "Click here http://aclpune.com/ems to login";

            new EmailManager(_configuration, _repository).SendEmail(subject, body, To, null);
            user.Password = Helper.Encrypt(password);
            _repository.Users.UpdateAndSave(user);
            _repository.Users.Dispose();
            return(Ok());
        }
示例#2
0
        public IActionResult Create([FromRoute] int id, [FromBody] Person person)
        {
            if (id == 0)
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                person.TenantId = TenantId;
                _repository.Employee.CreateAndSave(person);
                Users u = new Users
                {
                    TenantId = TenantId,
                    UserName = person.EmailAddress,
                    Password = EmailManager.CreateRandomPassword(8),
                    PersonId = person.Id
                };
                string pw = u.Password;
                u.CreatedBy = person.CreatedBy;
                _repository.Users.CreateUserAndSave(u);
                string To      = person.EmailAddress;
                string subject = "Employee Registration";
                string body    = "Dear " + GetTitle(person.Gender) + " " + person.FullName + ",\n" +
                                 "Your information have been successfully registered with Employee Management System.\n" +
                                 "Your Code Number: " + person.EmployeeCode + "\n" +
                                 "User Name: " + person.EmailAddress + "\n" +
                                 "Password: "******"\n" +
                                 "Click here http://aclpune.com/ems to login";
                new EmailManager(_configuration, _repository).SendEmail(subject, body, To, null);
                _repository.Users.Dispose();
                return(Ok(person));
            }
            else
            {
                Person per = _repository.Employee.FindByConditionWithNoTracking(x => x.Id == person.Id);
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                _repository.Employee.UpdateAndSave(person);
                if (person.IsOnProbation == false && per.IsOnProbation == true)
                {
                    _repository.Employee.UpdateProbation(person.Id, 0);
                }
                else if (per.JoinDate.Date != person.JoinDate.Date || (person.IsOnProbation == true && person.PropbationPeriodInMonth != per.PropbationPeriodInMonth))
                {
                    _repository.Employee.UpdateProbation(person.Id, Convert.ToInt32(person.PropbationPeriodInMonth));
                }

                Users u = _repository.Users.FindByCondition(x => x.PersonId == person.Id);
                u.UserName = person.EmailAddress;
                _repository.Users.UpdateAndSave(u);
                string To      = person.EmailAddress;
                string subject = "Employee Registration";
                string body    = "Dear " + GetTitle(person.Gender) + " " + person.FullName + ",\n" +
                                 "Your Information has been successfully updated with Employee Management System.\n" +
                                 "User Name: " + person.EmailAddress + "\n";
                new EmailManager(_configuration, _repository).SendEmail(subject, body, To, null);
                _repository.Employee.Dispose();
                return(Ok(person));
            }
        }