Esempio n. 1
0
        public ActionResult UpdateAccountSettings(tb_employer_registration_data changed_employer_data)
        {
            db = new DinJobPortalEntities();

            tb_user existing_user_data;

            try
            {
                //tb_user user;
                existing_user_data = (tb_user)Session["user"];
                if (existing_user_data != null)
                {
                    if (existing_user_data.user_type == "employer")
                    {
                        var previous_email = existing_user_data.email;
                        existing_user_data       = db.tb_user.Where(tempuser => tempuser.id == existing_user_data.id).Include(tempuser => tempuser.tb_employer_registration_data).FirstOrDefault <tb_user>();
                        existing_user_data.email = changed_employer_data.email;
                        existing_user_data.tb_employer_registration_data.FirstOrDefault().email        = changed_employer_data.email;
                        existing_user_data.tb_employer_registration_data.FirstOrDefault().first_name   = changed_employer_data.first_name;
                        existing_user_data.tb_employer_registration_data.FirstOrDefault().last_name    = changed_employer_data.last_name;
                        existing_user_data.tb_employer_registration_data.FirstOrDefault().company_name = changed_employer_data.company_name;
                        existing_user_data.tb_employer_registration_data.FirstOrDefault().mobile       = changed_employer_data.mobile;
                        existing_user_data.tb_employer_registration_data.FirstOrDefault().cnic         = changed_employer_data.cnic;
                        if (ModelState.IsValid)
                        {
                            db.Entry(existing_user_data).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                            Session["user"] = existing_user_data;
                            if (previous_email != existing_user_data.email)
                            {
                                Random  rnd      = new Random();
                                decimal randomNo = rnd.Next(10000000, 99999999);
                                objUtility = new UtilityMethods.Utility();
                                bool isEmailSent = objUtility.SendVerificationEmail(existing_user_data.email, randomNo);
                                if (isEmailSent)
                                {
                                    Session["user_email"]        = existing_user_data.email;
                                    Session["verification_code"] = randomNo;
                                    return(RedirectToAction("VerifyEmail", "User"));
                                }
                            }
                            return(RedirectToAction("AccountSetting"));
                        }
                        else
                        {
                            return(View("AccountSetting", existing_user_data));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                objUtility = new UtilityMethods.Utility();
                objUtility.SaveException_for_ExceptionLog(e);
                ViewBag.Exception = e.Message;
                return(RedirectToAction("DbError", "User", e));
            }
            return(View("AccountSetting"));
        }
Esempio n. 2
0
 public ActionResult UpdateProfile(tb_profile_employer employer)
 {
     try
     {
         db = new DinJobPortalEntities();
         tb_user             session_user;
         tb_profile_employer profile;
         session_user = (tb_user)Session["user"];
         if (session_user != null)
         {
             if (string.IsNullOrEmpty(employer.summary))
             {
                 ViewBag.Summary = "Kindly write Summary of your company";
                 return(View("EditProfile", session_user));
             }
             if (employer.no_of_employees == null)
             {
                 ViewBag.Employees = "Provide No of Employees";
                 return(View("EditProfile", session_user));
             }
             if (employer.company_establishment_date == null)
             {
                 ViewBag.Date = "Provide Company EStablishment Date";
                 return(View("EditProfile", session_user));
             }
             if (employer.company_location == null)
             {
                 ViewBag.Location = "Provide Company Location";
                 return(View("EditProfile", session_user));
             }
             employer.summary = Regex.Replace(employer.summary, @"\r\n?|\n", "<br />");
             profile          = db.tb_profile_employer.Where(pro => pro.email == session_user.email).FirstOrDefault();
             //profile = session_user.tb_profile_employee;
             profile.summary                    = employer.summary;
             profile.company_location           = employer.company_location;
             profile.no_of_employees            = employer.no_of_employees;
             profile.company_establishment_date = employer.company_establishment_date;
             db.Entry(profile).State            = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             Session["user"] = session_user;
             return(RedirectToAction("Dashboard"));
         }
         else
         {
             return(RedirectToAction("MyAccount", "User"));
         }
     }
     catch (Exception e)
     {
         objUtility = new UtilityMethods.Utility();
         objUtility.SaveException_for_ExceptionLog(e);
         ViewBag.Exception = e.Message;
         return(RedirectToAction("DbError", "User", e));
     }
     //return View();
 }
Esempio n. 3
0
        public ActionResult UpdateProfilePicture(HttpPostedFileBase profile_picture)
        {
            try
            {
                db = new DinJobPortalEntities();
                tb_profile_employer profile;
                tb_user             session_user;
                session_user = (tb_user)Session["user"];
                if (profile_picture != null)
                {
                    if (session_user != null)
                    {
                        profile = db.tb_profile_employer.Where(pro => pro.user_id == session_user.id).FirstOrDefault();
                        if (profile != null)
                        {
                            string new_profile_name = session_user.email + Path.GetExtension(profile_picture.FileName);

                            string path = Path.Combine(Server.MapPath("~/Employer_Profile_images"), new_profile_name);
                            profile_picture.SaveAs(path);
                            profile.profile_picture = new_profile_name;
                            db.Entry(profile).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                            tb_profile_employer pr = db.tb_profile_employer.Where(pro => pro.email == session_user.email)
                                                     .Include(pro => pro.tb_department_employer)
                                                     .FirstOrDefault();
                            session_user.tb_profile_employer.Clear();
                            session_user.tb_profile_employer.Add(pr);
                            Session["user"] = session_user;
                            return(RedirectToAction("DashBoard"));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("MyAccount", "User"));
                    }
                }
            }
            catch (Exception e)
            {
                objUtility = new UtilityMethods.Utility();
                objUtility.SaveException_for_ExceptionLog(e);
                ViewBag.Exception = e.Message;
                return(RedirectToAction("DbError", "User", e));
            }
            return(RedirectToAction("Dashboard"));
        }
        public static void Master_fill()
        {
            var db = new DinJobPortalEntities();

            master_list = db.tb_master_masters.ToList();
        }
Esempio n. 5
0
        public ActionResult UpdatePassword(string new_password, string old_password, string new_password_reenter)
        {
            db = new DinJobPortalEntities();

            tb_user existing_user_data;

            try
            {
                //tb_user user;
                existing_user_data = (tb_user)Session["user"];
                if (existing_user_data != null)
                {
                    if (existing_user_data.user_type == "employer")
                    {
                        ModelState.Clear();
                        existing_user_data = db.tb_user.Where(tempuser => tempuser.id == existing_user_data.id).Include(tempuser => tempuser.tb_employer_registration_data).FirstOrDefault <tb_user>();
                        TryValidateModel(existing_user_data);
                        string encPassword = enc.encryptPassword(old_password);
                        if (encPassword != existing_user_data.password)
                        {
                            ViewBag.ErrorMessage = "Old Password does not match";
                            return(View("AccountSetting", existing_user_data));
                        }
                        encPassword = enc.encryptPassword(new_password);
                        if (encPassword == existing_user_data.password)
                        {
                            ViewBag.ErrorMessage = "New and old Passwords should not be same";
                            return(View("AccountSetting", existing_user_data));
                        }
                        if (new_password != new_password_reenter)
                        {
                            ViewBag.ErrorMessage = "New Password and Re enter Password should be same";
                            return(View("AccountSetting", existing_user_data));
                        }
                        if (new_password.Length < 6 || new_password.Length > 32)
                        {
                            ViewBag.ErrorMessage = "Password Length must be atleast 6 Characters";
                            return(View("AccountSetting", existing_user_data));
                        }
                        existing_user_data.password = new_password;
                        TryValidateModel(existing_user_data);
                        if (ModelState.IsValid)
                        {
                            existing_user_data.password             = encPassword;
                            existing_user_data.last_change_password = old_password;
                            db.Entry(existing_user_data).State      = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                            Session["user"] = existing_user_data;
                            return(RedirectToAction("AccountSetting"));
                        }
                        else
                        {
                            return(View("AccountSetting", existing_user_data));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                objUtility = new UtilityMethods.Utility();
                objUtility.SaveException_for_ExceptionLog(e);
                ViewBag.Exception = e.Message;
                return(View("DbError", "User", e));
            }
            return(View("AccountSetting"));
        }