Пример #1
0
        public IHttpActionResult PostEmployee(Employee employee)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                if (DBOperations.IsUsernameExist(employee.UserName))
                {
                    return(BadRequest("Username Already Exists"));
                }
                if (DBOperations.IsEmailExist(employee.Email_ID))
                {
                    return(BadRequest("Email ID Already Exists"));
                }
                employee.IsEmailVerified = false;

                string VerificationCode = Guid.NewGuid().ToString();
                var    userName         = Encode.Base64Encode(employee.UserName);
                var    link             = "http://localhost:4200/setpassword/" + HttpUtility.UrlEncode(userName);
                VerificationLink.EmailGeneration(employee.Email_ID, VerificationCode, link);

                db.Employees.Add(employee);
                db.SaveChanges();
                DBOperations.UpdateUserinfo(employee.ID, employee.UserName);
                CallStoredProc.RunLeaveEntryForNew(employee);
                return(Ok("Successfully Added"));
            }
            catch (Exception ex)
            {
                LogFile.WriteLog(ex);
                return(BadRequest());
            }
        }
Пример #2
0
        public IHttpActionResult PostEmployee(Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (DBOperations.IsUsernameExist(employee.UserName))
            {
                return(Conflict());
            }
            if (DBOperations.IsEmailExist(employee.Email_ID))
            {
                return(Conflict());
            }
            employee.IsEmailVerified = false;

            string VerificationCode = Guid.NewGuid().ToString();
            var    link             = HttpContext.Current.Request.Url.AbsoluteUri + "/VerifyAccount/" + employee.UserName;

            VerificationLink.EmailGeneration(employee.Email_ID, VerificationCode, link);

            db.Employees.Add(employee);
            db.SaveChanges();
            CallStoredProc.RunLeaveEntryForNew(employee);
            return(Ok("Successfully Added"));
        }