예제 #1
0
        public string ResetPassword([FromBody] ResetPasswordModel model)
        {
            var repository = new ICONHRRepository();
            var empDetails = new EmployeeDetails();

            empDetails.Email = model.Email;
            string responseMsg = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(model.Password))
                {
                    //model.Password = PasswordHash.CreateHash(model.Password);

                    empDetails.Password     = model.Password;
                    empDetails.PasswordSalt = model.Password;
                    empDetails.PasswordHash = model.Password;
                    responseMsg             = repository.ResetPassword(empDetails);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(responseMsg);
        }
예제 #2
0
        // GET: ResetPassword
        public ActionResult Index()
        {
            repository  = new ICONHRRepository();
            empDetails  = new EmployeeDetails();
            responseMsg = string.Empty;

            try
            {
                if (Request["T"] != null)
                {
                    empDetails.PasswordToken = Convert.ToString(Request["T"]).Trim();
                    responseMsg = repository.CheckPasswordToken(empDetails);
                    if (responseMsg.Trim().ToLower() == "fail")
                    {
                        TempData["ErrorMessage"] = "Reset password link expired";
                        return(RedirectToAction("Index", "Message"));
                    }
                }
                else
                {
                    return(RedirectToAction("Index", "Login"));
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(View());
        }
예제 #3
0
 public string EditEmployee(string firstName, string lastName, string email, string phone, string gender, string upload, string address, string dob, string postalCode, int country)
 {
     responseMsg = string.Empty;
     try
     {
         var profilePhoto = System.Convert.FromBase64String(upload);
         empDetails = new EmployeeDetails
         {
             Emp_ID       = Convert.ToInt32(Session["EmpID"]),
             Emp_Name     = firstName + " " + lastName,
             Email        = email,
             PhoneNumber  = phone,
             Gender       = gender,
             Address      = address,
             ProfilePhoto = profilePhoto,
             DOB          = dob,
             PostalCode   = postalCode,
             Country_ID   = country
         };
         responseMsg = repository.UpdateEmpDetailsByEmpId(empDetails);
     }
     catch (Exception ex)
     {
         System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
         var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
         int    Line           = (int)frame.GetFileLineNumber();
         string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
         string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
         LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
     }
     return(responseMsg);
 }
예제 #4
0
        public string AddEmployeeDetails(string empName, string email, string phoneNumber, string password, string company, string companySize, string profilePhoto)
        {
            empDetails = new EmployeeDetails();
            string passwordHashSalt = string.Empty;
            int    empId            = 0;

            try
            {
                #region Password Encryption
                passwordHashSalt = PasswordHash.CreateHash(password);
                string[] passwordValues = passwordHashSalt.Split(':');
                #endregion
                var PhotoBase64 = System.Convert.FromBase64String(profilePhoto);
                empDetails.Emp_Name     = empName;
                empDetails.Emp_Role     = 2;
                empDetails.Email        = email;
                empDetails.PasswordSalt = password; //Convert.ToString(passwordValues[1]).Trim();
                empDetails.PasswordHash = Convert.ToString(passwordValues[2]).Trim();
                empDetails.PhoneNumber  = phoneNumber;
                empDetails.Gender       = "";
                empDetails.DOB          = "";
                empDetails.ProfilePhoto = PhotoBase64;
                empDetails.Company_Name = Convert.ToString(Session["CompanyName"]);
                empDetails.Address      = "";
                empDetails.Country_ID   = 1;
                empDetails.PostalCode   = "";
                empDetails.Created_By   = Convert.ToString(Session["EmpName"]);
                responseMsg             = repository.AddNewEmpDetails(empDetails);
                string[] response = responseMsg.Split(',');
                if (response.Length == 2)
                {
                    responseMsg = Convert.ToString(response[0]);
                }
                else
                {
                    responseMsg = "Fail";
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(responseMsg);
        }
예제 #5
0
        public string ChangePassword(string oldPassword, string password)
        {
            repository = new ICONHRRepository();
            empDetails = new EmployeeDetails();
            DataTable dt_OldPwdDetails = new DataTable();

            responseMsg = string.Empty;
            bool oldPasswordExists = false;

            try
            {
                if (Session["EmpID"] != null)
                {
                    empDetails.Emp_ID = Convert.ToInt32(Session["EmpID"]);
                    dt_OldPwdDetails  = repository.GetLoginDetailsByEmpId(empDetails);

                    if (dt_OldPwdDetails.Rows.Count > 0)
                    {
                        oldPasswordExists = PasswordHash.ValidatePassword(oldPassword, "1000:" + Convert.ToString(dt_OldPwdDetails.Rows[0]["PasswordSalt"]) + ":" + Convert.ToString(dt_OldPwdDetails.Rows[0]["PasswordHash"]));
                    }

                    if (oldPasswordExists)
                    {
                        repository = new ICONHRRepository();
                        password   = PasswordHash.CreateHash(Convert.ToString(password).Trim());
                        string[] myNewPwd = password.Split(':');
                        empDetails.PasswordSalt    = Convert.ToString(myNewPwd[1]).Trim();
                        empDetails.PasswordHash    = Convert.ToString(myNewPwd[2]).Trim();
                        empDetails.Emp_ID          = Convert.ToInt32(Session["EmpID"]);
                        empDetails.Last_Updated_By = Convert.ToString(Session["EmpName"]).Trim();

                        responseMsg = repository.ChangePassword(empDetails);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(responseMsg);
        }
        public string Post(ChangePasswordModel model)
        {
            var       repository        = new ICONHRRepository();
            var       empDetails        = new EmployeeDetails();
            DataTable dt_OldPwdDetails  = new DataTable();
            string    responseMsg       = string.Empty;
            bool      oldPasswordExists = false;

            try
            {
                if (!string.IsNullOrEmpty(UserIdentity))
                {
                    empDetails.Emp_ID = Convert.ToInt32(UserIdentity);
                    dt_OldPwdDetails  = repository.GetLoginDetailsByEmpId(empDetails);

                    if (dt_OldPwdDetails.Rows.Count > 0)
                    {
                        //oldPasswordExists = PasswordHash.ValidatePassword(model.OldPassword, "1000:" + Convert.ToString(dt_OldPwdDetails.Rows[0]["PasswordSalt"]) + ":" + Convert.ToString(dt_OldPwdDetails.Rows[0]["PasswordHash"]));
                        oldPasswordExists = Convert.ToString(dt_OldPwdDetails.Rows[0]["PasswordSalt"]) ==
                                            model.OldPassword;
                    }

                    if (model.OldPassword == dt_OldPwdDetails.Rows[0]["PasswordSalt"].ToString())
                    {
                        repository = new ICONHRRepository();
                        //model.NewPassword = PasswordHash.CreateHash(Convert.ToString(model.NewPassword).Trim());
                        // string[] myNewPwd = model.NewPassword.Split(':');
                        empDetails.PasswordSalt = model.NewPassword; //myNewPwd[1]; //Convert.ToString(myNewPwd[1]).Trim();
                        //empDetails.PasswordHash = Convert.ToString(myNewPwd[2]).Trim();
                        empDetails.Emp_ID          = Convert.ToInt32(UserIdentity);
                        empDetails.Last_Updated_By = Convert.ToString(UserIdentity).Trim(); // TODO it shold not be id instead use name

                        responseMsg = repository.ChangePassword(empDetails);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }
            return(responseMsg);
        }
예제 #7
0
        public string ForgotPassword([FromBody] ResetPasswordModel model)
        {
            DataTable dt_ForgotPassword = new DataTable();
            var       repository        = new ICONHRRepository();
            var       empDetails        = new EmployeeDetails();
            string    szBody            = string.Empty;
            string    EmployeeName      = string.Empty;
            string    url         = string.Empty;
            string    webAddress  = ConfigurationManager.AppSettings["ICONHRUrl"];
            var       responseMsg = string.Empty;

            try
            {
                string RandomToken = RandomString(12, true);
                empDetails.Email         = Convert.ToString(model.Email).Trim();
                empDetails.PasswordToken = RandomToken;
                dt_ForgotPassword        = repository.ForgotPassword(empDetails);
                if (dt_ForgotPassword != null && dt_ForgotPassword.Rows.Count > 0)
                {
                    EmployeeName = Convert.ToString(dt_ForgotPassword.Rows[0]["EmpName"]).Trim();
                    url          = "<a href='" + webAddress + "/ResetPassword?T=" + RandomToken + "'>Reset Password</a>";
                    szBody       = Mailtemplate.PrepareMailBodyWith("ResetPassword.html",
                                                                    "URL", url,
                                                                    "EmployeeName", EmployeeName.ToUpper());
                    Mail email = new Mail();
                    email.SendEmail("ICON HR - Reset Password", szBody, model.Email);
                    responseMsg = "Success";
                }
                else
                {
                    responseMsg = "False";
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(responseMsg);
        }
예제 #8
0
        public bool Login(string email, string password)
        {
            var ValidateUser = false;

            repository      = new ICONHRRepository();
            empDetails      = new EmployeeDetails();
            dt_LoginDetails = new DataTable();

            try
            {
                empDetails.Email = Convert.ToString(email);
                dt_LoginDetails  = repository.GetLoginDetails(empDetails);
                if (dt_LoginDetails != null && dt_LoginDetails.Rows.Count > 0)
                {
                    bool passwordValue = PasswordHash.ValidatePassword(password, "1000:" + Convert.ToString(dt_LoginDetails.Rows[0]["PasswordSalt"]) + ":" + Convert.ToString(dt_LoginDetails.Rows[0]["PasswordHash"]));

                    if (passwordValue)
                    {
                        Session["EmpID"]       = Convert.ToString(dt_LoginDetails.Rows[0]["EmpID"]);
                        Session["EmpName"]     = Convert.ToString(dt_LoginDetails.Rows[0]["EmpName"]);
                        Session["EmpRole"]     = Convert.ToString(dt_LoginDetails.Rows[0]["EmpRoleID"]);
                        Session["CompanyName"] = Convert.ToString(dt_LoginDetails.Rows[0]["CompanyName"]);
                        Session["RepMgrID"]    = Convert.ToString(dt_LoginDetails.Rows[0]["RepMgrID"]);
                        ValidateUser           = true;
                    }
                }
                else
                {
                    ValidateUser = false;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(ValidateUser);
        }
예제 #9
0
        public string AddNewEmpDetails(string empName, string email, string phoneNumber, string password, string company, string companySize)
        {
            empDetails  = new EmployeeDetails();
            responseMsg = string.Empty;
            string passwordHashSalt = string.Empty;

            try
            {
                #region Password Encryption
                passwordHashSalt = PasswordHash.CreateHash(password);
                string[] passwordValues = passwordHashSalt.Split(':');
                #endregion
                empDetails.Emp_Name     = empName;
                empDetails.Emp_Role     = 1;
                empDetails.Email        = email;
                empDetails.PhoneNumber  = phoneNumber;
                empDetails.PasswordSalt = password; //Convert.ToString(passwordValues[1]).Trim();
                //empDetails.PasswordHash = Convert.ToString(passwordValues[2]).Trim();
                empDetails.Company_Name = company;
                empDetails.Company_Size = companySize;
                empDetails.Created_By   = empName;

                responseMsg = repository.CheckEmailId(empDetails);

                if (responseMsg == response)
                {
                    Session["EmployeeModel"] = empDetails;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(responseMsg);
        }
예제 #10
0
        public string GetCountryAndCardDetails()
        {
            repository = new ICONHRRepository();
            DataSet ds_CountryAndCardDetails = new DataSet();
            string  data = string.Empty;

            try
            {
                ds_CountryAndCardDetails = repository.GetCountryAndCardDetails();
                data = JsonConvert.SerializeObject(ds_CountryAndCardDetails);
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(data);
        }
예제 #11
0
        public string GetProfileImage()
        {
            repository = new ICONHRRepository();
            DataSet dt         = new DataSet();
            string  data       = string.Empty;
            int     employeeId = 0;

            if (Session["EmpID"] != null)
            {
                employeeId = int.Parse(Session["EmpID"].ToString());
            }
            else
            {
                return(string.Empty);
            }

            try
            {
                byte[] logo = repository.GetProfileImageById(employeeId);
                // data = JsonConvert.SerializeObject(dt);
                // byte[] byt = Convert.FromBase64String("aQBWAEIATwBSAHcAMABLAEcAZwBvAEEAQQBBAEEA");
                string imgData      = Base64EncodeBytes(logo);
                string base64String = Convert.ToBase64String(logo);
                return(imgData);
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(data);
        }
예제 #12
0
        public string CreditCardAndBillingDetails(string cardHolderName, int cardType, string cardNumber, int CVV, int cardExpMonth, int cardExpYear,
                                                  string Name, string address, int country, string postalCode, string phoneNumber, string email)
        {
            empDetails  = new EmployeeDetails();
            ccDetails   = new CreditCardDetails();
            repository  = new ICONHRRepository();
            responseMsg = string.Empty;
            int empId = 0;

            try
            {
                //Employee details
                empDetails            = (EmployeeDetails)Session["EmployeeModel"];
                empDetails.Country_ID = Convert.ToInt32(country);
                responseMsg           = repository.AddNewEmpDetails(empDetails);

                string[] arrResponse = responseMsg.Split(',');
                if (response.Length > 1)
                {
                    responseMsg = Convert.ToString(arrResponse[0]);
                    empId       = Convert.ToInt32(arrResponse[1]);
                    if (empId != 0)
                    {
                        // Card Card details
                        repository                  = new ICONHRRepository();
                        ccDetails.Emp_ID            = empId;
                        ccDetails.CardHolder        = cardHolderName;
                        ccDetails.CardTypeID        = cardType;
                        ccDetails.CardNumber        = cardNumber;
                        ccDetails.CVV               = CVV;
                        ccDetails.Card_Exp_Month_ID = cardExpMonth;
                        ccDetails.Card_Exp_Year_ID  = cardExpYear;

                        // Billing details
                        ccDetails.Name               = Name;
                        ccDetails.Address            = address;
                        ccDetails.Country_ID         = country;
                        ccDetails.PostalCode         = postalCode;
                        ccDetails.BillingEmail       = email;
                        ccDetails.BillingPhoneNumber = phoneNumber;
                        ccDetails.Created_By         = empDetails.Created_By;

                        responseMsg = repository.AddCreditCardDetails(ccDetails);

                        if (responseMsg == response)
                        {
                            Session["EmployeeModel"] = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                var    frame          = trace.FrameCount > 1 ? trace.GetFrame(1) : trace.GetFrame(0);
                int    Line           = (int)frame.GetFileLineNumber();
                string methodName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                LogClass.CreateLogXml(ex.Message, controllerName, Convert.ToString(ex.InnerException), methodName, Line);
            }

            return(responseMsg);
        }