Example #1
0
        public bool AddUserBL(UserViewModel vmodel)
        {
            UserDL udl        = new UserDL();
            var    userreturn = udl.AddUser(vmodel);

            return(userreturn);
        }
Example #2
0
        public ActionResult JobSeekerRegistration(User ObjUser)
        {
            if (!string.IsNullOrEmpty(ObjUser.FirstName) && !string.IsNullOrEmpty(ObjUser.LastName) && !string.IsNullOrEmpty(ObjUser.Email) && !string.IsNullOrEmpty(ObjUser.Password))
            {
                UserDL userDL = new UserDL();
                int    result;
                result = userDL.AddUserDetails(ObjUser);
                if (result == 1)
                {
                    //  SendMail(ObjUser.FirstName, ObjUser.LastName, ObjUser.Email);
                    TempData["Message"] = "Registraion Successfull!!";
                    ModelState.Clear();
                    //TempData["msg"] = "Your Account has been made, please verify it by clicking the activation link that has been send to your email.";
                    return(RedirectToAction("Login"));
                }
                else
                {
                    TempData["Message"] = "Already Email Registraion!!";
                    ModelState.Clear();
                    return(View());
                }
            }

            return(View());
        }
Example #3
0
    /// <summary>
    /// Checks if a user record with the defined password and username exists.
    /// </summary>
    /// <param name="username"></param>
    /// <param name="password"></param>
    /// <returns>1 if present, 0 if missing.</returns>
    public static int AuthenticateUser(string username, string password)
    {
        //Using an SQL connection.
        using (SqlConnection conn = new SqlConnection(Connection.ConnectionString(Connection.ConType.One)))
        {
            // Create SQL command, pass connection and name of stored procedure.
            SqlCommand command = new SqlCommand("GetUser", conn);

            // Declare that a store procedure is used.
            command.CommandType = CommandType.StoredProcedure;

            // Encript and reference encripted password.
            string hashedPassword = UserDL.EncriptPassword(password);

            // Pass parameters to stored procedures.
            command.Parameters.AddWithValue("@username", username);
            command.Parameters.AddWithValue("@password", hashedPassword);

            conn.Open();
            int result = Convert.ToInt32(command.ExecuteScalar());
            conn.Dispose();
            // If username already exists will return a value bigger than 0.
            return(result);
        }
    }
Example #4
0
        public static List <Object> RetrieveUsers()
        {
            try
            {
                string eKey = System.Configuration.ConfigurationManager.AppSettings.Get("ekey");

                List <User> users = UserDL.RetrieveUsers();

                List <Object> returnedUsers = new List <Object>();

                foreach (User user in users)
                {
                    object userObj = new
                    {
                        ID          = user.ID,
                        Lastname    = user.Lastname,
                        Othernames  = user.Othernames,
                        Gender      = user.Gender,
                        PhoneNumber = user.PhoneNumber,
                        Email       = user.Email,
                        Username    = user.Username,
                        CreatedOn   = String.Format("{0:dddd, MMMM d, yyyy}", Convert.ToDateTime(user.CreatedOn)),
                        Role        = new { ID = user.Role.ID, Name = user.Role.Name },
                        Branch      = new { ID = user.Branch.ID, Name = user.Branch.Name }
                    };

                    returnedUsers.Add(userObj);
                }
                return(returnedUsers);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
        public bool DeleteUserDetail(int userId)
        {
            objUserDL = new UserDL();
            var isSubmitted = objUserDL.DeleteUserDetail(userId);

            return(isSubmitted);
        }
Example #6
0
        public void ChangePassword(Guid id, string newpassword)
        {
            var userDL   = new UserDL();
            var pass_md5 = GetMD5Password(newpassword);

            userDL.ChangePassword(id, pass_md5);
        }
Example #7
0
        /// <summary>
        /// To get User details from DL using EF
        /// </summary>
        /// <returns></returns>

        public List <UserModel> GetUserDetails()
        {
            objUserDL = new UserDL();
            var vGetUserDetails = objUserDL.GetUserDetails();

            return(vGetUserDetails);
        }
Example #8
0
        /// <summary>
        /// Insert the User values which user entered to DB from DL using EF
        /// </summary>
        /// <param name="objGET_User_DETAILS_Result"></param>
        /// <returns></returns>
        public bool SubmitUserDetail(UserModel userModel)
        {
            objUserDL = new UserDL();
            var isSubmitted = objUserDL.SubmitUserDetail(userModel);

            return(isSubmitted);
        }
Example #9
0
        public string CreateUser(User user, int mode)
        {
            // validation
            string result = "Success";
            var    userDL = new UserDL();

            user.Password = GetMD5Password(user.Password);
            if (mode == 1)
            {
                if (string.IsNullOrWhiteSpace(user.Password))
                {
                    return("PasswordNotEmpty");
                }

                if (_users.Any(x => x.Username == user.Username))
                {
                    return("ExistUserName");
                }
                userDL.CreateUser(user);
            }
            else
            {
                userDL.UpdateUser(user);
            }
            return(result);
        }
        public ActionResult UserLogin(UserDL userDl)
        {
            UniversityContext context = new UniversityContext();

            if (userDl.Password == null)
            {
                ViewBag.PasswordValidation = "Password is required";
                return(View(userDl));
            }
            var searchUser = context.Users.Where(x => x.UserID == userDl.UserID &&
                                                 x.Password == userDl.Password).FirstOrDefault();

            if (searchUser == null) //if username and password is matching
            {
                ViewBag.isValidate    = 0;
                ViewBag.ValidationMsg = " Invalid User ID or Incorrect Password ";
                return(View(userDl));
            }
            else
            {
                Session["Name"]       = context.Users.Where(x => x.UserID == userDl.UserID).FirstOrDefault().FirstName;
                ViewBag.isValidate    = 1;
                ViewBag.ValidationMsg = " Logged in successfully ";
                Session["UserId"]     = userDl.UserID;
                return(RedirectToAction("HomePage", "Home"));
            }
        }
Example #11
0
        //---- LOGIN  ------------------------------------------------------------------------------------------------------------------------



        /// <summary>
        /// Author : Mir Bilal

        /// Remarks :
        /// 1. First calls the encrypt class to encrypt the password to be stored in the database.
        /// 2. calls the validate method in DL with the encrypt password for login.
        /// <returns></returns>
        public static DataTable ValidateUser(string Email, string password)
        {
            string    encryptpass = Encrypt.EncryptPassword(password);
            DataTable ds          = UserDL.ValidateUser(Email, encryptpass);

            return(ds);
        }
        public ActionResult Registration(UserDL user)
        {
            UniversityContext context = new UniversityContext();
            var ExistUser             = context.Users.Where(x => x.UserID == user.UserID).FirstOrDefault();

            if (ModelState.IsValid)
            {
                if (ExistUser != null)
                {
                    ViewBag.newUserValidate      = 0;
                    ViewBag.newUserValidationMsg = "User Already Registered ";
                }

                else
                {
                    context.Users.Add(user);
                    context.SaveChanges();
                    ViewBag.newUserValidate      = 1;
                    ViewBag.newUserValidationMsg = "Your details are submitted successfully";
                    return(View(user));
                }
            }

            return(View(user));
        }
Example #13
0
        /// <summary>
        /// Deletes the users.
        /// </summary>
        /// <param name="uList">The u list.</param>
        /// <returns></returns>
        public string DeleteUsers(string uList)
        {
            var    userDl = new UserDL();
            string result = userDl.DeleteUsers(uList);

            return(result);
        }
Example #14
0
        /// <summary>
        /// Deletes the user views.
        /// </summary>
        /// <param name="uvList">The uv list.</param>
        /// <returns></returns>
        public int DeleteUserViews(string uvList)
        {
            var userDl = new UserDL();
            int result = userDl.DeleteUserViews(uvList);

            return(result);
        }
Example #15
0
 public static bool Save(User user, out string message)
 {
     try
     {
         if (UserDL.UserExists(user))
         {
             message = string.Format("User with username: {0} exists already", user.Username);
             return(false);
         }
         else
         {
             message = string.Empty;
             if (UserDL.Save(user))
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #16
0
        /// <summary>
        /// Author : Mir Bilal

        /// Remark : Call to fetch email to check wheather a particular user with the particular email exists..
        /// <returns></returns>
        public static bool Fetchemail(string email)
        {
            if (UserDL.FetchEmail(email).Rows.Count > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #17
0
 public static User RetrieveUserByUsername(string username)
 {
     try
     {
         return(UserDL.RetrieveUserByUsername(username));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #18
0
 public static bool ChangePassword(string username, string password)
 {
     try
     {
         return(UserDL.ChangePassword(username, password));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #19
0
 public static bool Update(User user)
 {
     try
     {
         return(UserDL.Update(user));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #20
0
        //--------Examination Objective------------------------------------------Student----------------------------------------------------------------------------------------------


        /// <summary>
        /// Author : Mir Bilal

        /// Remark : Call to check wheather particular student has already submitted their answers for the Questions of particular subject....
        /// </summary>
        public static bool FetchRemark(int userid, int paperid)
        {
            if (UserDL.FetchRemark(userid, paperid).Rows.Count > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #21
0
        //-------Assignment--------------------------------------------------Student---------------------------------------------------------------------------

        public static bool AlreadySubmitAssignment(int userid, int classid, int subjectid, int assignmentid)
        {
            if (UserDL.AlreadySubmitAssignment(userid, classid, subjectid, assignmentid).Rows.Count > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #22
0
 public int SaveUserregisrationBL(User objUserBL) // passing Bussiness object Here
 {
     try
     {
         UserDL objUserdl = new UserDL();             // Creating object of Dataccess
         return(objUserdl.AddUserDetails(objUserBL)); // calling Method of DataAccess
     }
     catch
     {
         throw;
     }
 }
Example #23
0
 public IActionResult MaterialList()
 {
     try
     {
         var         userDL = new UserDL();
         List <User> users  = userDL.GetUsers();
         ViewBag.UserList = users;
         return(View());
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #24
0
        public ResultViewModel Get(int?id = null)
        {
            var rest = new ResultViewModel();

            try
            {
                rest.Response = UserDL.GetAllUsers(id);
            }
            catch (Exception ex)
            {
                rest.Error = ex.Message;
                // throw;
            }
            return(rest);
        }
Example #25
0
 public IActionResult InvoiceList()
 {
     try
     {
         var         userDL = new UserDL();
         List <User> users  = userDL.GetUsers();
         ViewBag.UserList = users;
         return(View());
     }
     catch (Exception)
     {
         return(BadRequest());
     }
     //var invoiceBL = new InvoiceBL();
     //List<Invoice> invoices = invoiceBL.GetInvoices();
     //ViewBag.InvoiceList = invoices;
 }
Example #26
0
        public ResultViewModel Post(RequestModel req)
        {
            var res = new ResultViewModel();

            try
            {
                //UserDL dl = new UserDL();
                var data = Extensions.GetPayLoad(req);
                res.Response = UserDL.AddUser(data);
                // TODO: Add insert logic here

                //return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                res.Error = ex.Message;
            }

            return(res);
        }
Example #27
0
        public static bool UserExists(string username, string password)
        {
            try
            {
                var user = new User();

                user = UserDL.AuthenticateUser(username, PasswordHash.MD5Hash(password));

                if (user == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #28
0
        public static dynamic AuthenticateUser(string username, string password)
        {
            try
            {
                User user = UserDL.AuthenticateUser(username, password);
                if (user != null)
                {
                    dynamic userObj = new ExpandoObject();

                    List <dynamic> userFunctions = new List <dynamic>();

                    Role userRole = RoleDL.RetrieveRoleByID(user.UserRole);
                    foreach (RoleFunction roleFunction in userRole.RoleFunctions)
                    {
                        dynamic function = new
                        {
                            Name     = roleFunction.Function.Name,
                            PageLink = roleFunction.Function.PageLink
                        };

                        userFunctions.Add(function);
                    }

                    userObj.ID       = user.ID;
                    userObj.Username = user.Username;
                    userObj.Role     = userRole.Name;
                    userObj.Function = userFunctions;
                    userObj.BranchID = BranchDL.RetrieveBranchByID(user.UserBranch).ID;

                    return(userObj);
                }
                return(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #29
0
        /// <summary>
        /// Gets the user tree by manager.
        /// </summary>
        /// <param name="clientId">The client identifier.</param>
        /// <returns></returns>
        public List <UserDto> GetUserTreeByManager(UserDto clientId)
        {
            var userDl = new UserDL();

            return(userDl.GetUserTreeByManager(clientId));
        }
Example #30
0
        /// <summary>
        /// Gets the managers.
        /// </summary>
        /// <param name="clientId">The client identifier.</param>
        /// <returns></returns>
        public List <UserDto> GetManagers(UserDto clientId)
        {
            var userDl = new UserDL();

            return(userDl.GetManagers(clientId));
        }