Esempio n. 1
0
        public IActionResult Post([FromBody] Employee employee)
        {
            if (!ModelState.IsValid)
            {
                _logger.AddLog(BadRequest(ModelState).ToString(), BadRequest().GetType().ToString());
                return(BadRequest(ModelState));
            }
            try
            {
                var doesExistAlready = _registerEmployee.IsEmpIdExist(employee.EmpId);
                if (doesExistAlready)
                {
                    return(StatusCode(StatusCodes.Status406NotAcceptable, "Employee ID exists"));
                }

                //Inside this post with image we are checking if this user.username (containing official email) already exists or not
                if (_registerEmployee.PostWithImage(employee) == true)
                {
                    _passwordResetService.GenerateAndSendEmail(employee.PersonalInfo.Email, employee.Username);
                    return(Ok());
                }
                return(BadRequest(ModelState));
            }
            catch (Exception E)
            {
                _logger.AddLog(E.ToString(), E.GetType().ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Esempio n. 2
0
        public async void GenerateLink(string email, int empId, string personalEmail)
        {
            PasswordReset passReset;

            passReset = _passwordResetService.GetObjUsingOfficialEmail(email);
            _passwordResetService.Remove(passReset);
            await _unitOfWork.Complete();

            //_passwordResetService.Update(passReset); We do not need this line because while generating a new email, a new record is entered
            _passwordResetService.GenerateAndSendEmail(personalEmail, email);
        }