예제 #1
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();
 }
예제 #2
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"));
        }
예제 #3
0
        public ActionResult CreateProfileFirstTime(tb_profile_employer employer_profile, HttpPostedFileBase profile_picture, HttpPostedFileBase cover_picture)
        {
            tb_user existing_user_data;

            try
            {
                ModelState.Clear();
                existing_user_data = (tb_user)Session["user"];
                if (existing_user_data != null)
                {
                    employer_profile.email = existing_user_data.email;
                    if (profile_picture != null && profile_picture.ContentLength > 0)
                    {
                        try
                        {
                            string new_profile_name = existing_user_data.email + Path.GetExtension(profile_picture.FileName);

                            string path = Path.Combine(Server.MapPath("~/Employer_Profile_images"), new_profile_name);
                            profile_picture.SaveAs(path);
                            employer_profile.profile_picture = new_profile_name;
                        }
                        catch (Exception ex)
                        {
                            ViewBag.Message = "ERROR:" + ex.Message.ToString();
                        }
                    }
                    else
                    {
                        ViewBag.Message = "Please select file";
                    }
                    if (cover_picture != null && cover_picture.ContentLength > 0)
                    {
                        try
                        {
                            string new_cover_name = existing_user_data.email + Path.GetExtension(cover_picture.FileName);
                            string path           = Path.Combine(Server.MapPath("~/Employer_Cover_images"), new_cover_name);
                            cover_picture.SaveAs(path);
                            employer_profile.cover_picture = new_cover_name;
                        }
                        catch (Exception ex)
                        {
                            ViewBag.Message = "ERROR:" + ex.Message.ToString();
                        }
                    }
                    else
                    {
                        ViewBag.Message = "Please select file";
                    }
                }
                objUtility = new UtilityMethods.Utility();
                employer_profile.user_id = existing_user_data.id;
                List <tb_department_employer> employer_department_list = objUtility.GetDepartmentList(existing_user_data.id, Request["department_name"], Request["no_of_employee_in_department"], Request["department_intro"]);

                employer_profile.tb_department_employer = employer_department_list;
                TryValidateModel(employer_profile);
                if (ModelState.IsValid)
                {
                    try
                    {
                        db.tb_profile_employer.Add(employer_profile);
                        db.SaveChanges();
                        int id = employer_profile.id;
                        return(RedirectToAction("Dashboard"));
                    }
                    catch (Exception e)
                    {
                        objUtility = new UtilityMethods.Utility();
                        objUtility.SaveException_for_ExceptionLog(e);
                        ViewBag.Exception = e.Message;
                        return(RedirectToAction("DbError", "User", e));
                    }
                }
            }
            catch (Exception e)
            {
                objUtility = new UtilityMethods.Utility();
                objUtility.SaveException_for_ExceptionLog(e);
                ViewBag.Exception = e.Message;
                return(RedirectToAction("DbError", "User", e));
            }
            return(View("CompleteProfile"));
        }