Beispiel #1
0
        public bool registerEmployee(RegisterViewModel user)
        {
            try
            {
                user.SALT = CreateSalt();
                user.ID = Guid.NewGuid().ToString();
                user.PASSWORD = CreatePasswordHash(user.PASSWORD, user.SALT);
                user.ROLE = "SA";

                USER objUser = new USER
                {
                    ID = user.ID,
                    EMP_ID = user.REG_EMP_ID,
                    PASSWORD = user.PASSWORD,
                    ROLE = user.ROLE,
                    SALT = user.SALT
                };

                using (var context = new HMSDBEntities())
                {
                    context.USERs.Add(objUser);
                    context.SaveChanges();
                }

                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public string getEmpId(string user)
        {
            try
            {
                string emp_id = user;

                using (var context = new HMSDBEntities())
                {
                        var empid = from u in context.USERs
                                where u.EMP_ID == emp_id
                                select u;

                    if (empid.ToList().Count == 1)
                    {
                        return emp_id.ToString();
                    }
                }
                return "";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }