public ActionResult EditImg(HttpPostedFileBase IMG)
        {
            var cookie = new FunctionController();
            var idus   = cookie.CookieID();

            User user = db.Users.Find(idus.user_id);

            if (IMG == null)
            {
                user.user_img = idus.user_img;
            }
            else
            {
                var code = Guid.NewGuid().ToString();
                var img  = new FunctionController();
                img.AddImages(IMG, Common.Common.LINK_USER, code);
                user.user_img = code + IMG.FileName;
            }
            db.SaveChanges();

            return(Redirect("/Users/MyInfo?id=" + idus.user_id));
        }
        public ActionResult CreateAD([Bind(Include = "news_id,news_title,news_contents,news_image,cate_id,news_tags,news_genres,news_datecreate,news_dateupdate,news_active,news_option,news_bin,user_id,news_view")] News news, HttpPostedFileBase img)
        {
            var coo = new FunctionController();

            var code = Guid.NewGuid().ToString();

            var addi = coo.AddImages(img, Common.Common.LINK_NEW, code);

            news.news_image = addi;

            news.cate_id         = 2;
            news.news_datecreate = DateTime.Now;
            news.news_dateupdate = DateTime.Now;
            news.news_active     = false;
            news.news_option     = true;
            news.news_bin        = false;
            news.news_view       = 1;
            news.user_id         = coo.CookieIDEm().user_id;
            db.News.Add(news);
            db.SaveChanges();

            ViewBag.user_id = new SelectList(db.Users, "user_id", "user_email", news.user_id);
            return(RedirectToAction("Index"));
        }
        //Them hoan toan cv
        public ActionResult Edit(Cv cV, HttpPostedFileBase IMG)
        {
            var  f  = new FunctionController();
            User id = f.CookieID();

            Cv cV1 = db.Cvs.Find(cV.cv_id);

            cV.theme_id      = cV1.theme_id;
            cV.cv_datecreate = DateTime.Now;
            cV.cv_dateupdate = DateTime.Now;
            cV.user_id       = cV1.user_id;

            if (cV.cv_point >= 80)
            {
                cV.cv_active = 1;
                cV.cv_option = true;
            }
            else if (cV.cv_point >= 65)
            {
                cV.cv_active = 1;
                cV.cv_option = true;
            }
            else
            {
                cV.cv_active = 2;
                cV.cv_option = false;
            }

            cV.cv_bin      = cV1.cv_bin;
            cV.cv_fakeid   = cV1.cv_fakeid;
            cV.cv_deadline = DateTime.Now.AddMonths(1);
            cV.cv_view     = cV1.cv_view;
            cV.cv_bg       = "darkcyan";

            cV.cv_p = 1;

            var img  = new FunctionController();
            var code = Guid.NewGuid().ToString();

            if (IMG == null)
            {
                cV.cv_img = cV1.cv_img;
            }
            else
            {
                img.AddImages(IMG, Common.Common.LINK_CV, code);
                cV.cv_img = code + IMG.FileName;
            }

            if (cV.cv_title == null)
            {
                cV.cv_title = cV.cv_fullname + " " + cV1.cv_fakeid.Substring(0, 6);
            }


            var dao = new CvsDao();

            if (dao.Edit(cV))
            {
                return(Redirect("/Cvs/IndexCvs"));
            }
            else
            {
                return(Redirect("/"));
            }
        }
        public ActionResult PersonalPage(User user, HttpPostedFileBase logo, HttpPostedFileBase banner)
        {
            var code1 = Guid.NewGuid().ToString();
            var code2 = Guid.NewGuid().ToString();

            var fu = new FunctionController();
            var id = fu.CookieIDEm();

            //Logo
            if (logo == null)
            {
                user.employer_logo = id.employer_logo;
            }
            else
            {
                var img = fu.AddImages(logo, Common.Common.LINK_EMPLOYER, code1);
                user.employer_logo = img;
            }

            //Banner
            if (banner == null)
            {
                user.employer_banner = "satisfied-job.jpg";
            }
            else
            {
                var img = fu.AddImages(banner, Common.Common.LINK_EMPLOYER, code2);
                user.employer_banner = img;
            }

            if (id.employer_pageload == null)
            {
                user.employer_pageload = false;
            }
            else
            {
                user.employer_pageload = id.employer_pageload;
            }

            user.user_id           = id.user_id;
            user.user_email        = id.user_email;
            user.user_pass         = id.user_pass;
            user.user_active       = id.user_active;
            user.user_option       = id.user_option;
            user.user_datecreate   = id.user_datecreate;
            user.user_dateupdate   = id.user_dateupdate;
            user.user_img          = id.user_img;
            user.user_sex          = id.user_sex;
            user.user_birth        = id.user_birth;
            user.user_favourite    = id.user_favourite;
            user.role_id           = id.role_id;
            user.user_name         = id.user_name;
            user.user_phone        = id.user_phone;
            user.user_note         = id.user_note;
            user.user_key          = id.user_key;
            user.wp_id             = id.wp_id;
            user.version_id        = id.version_id;
            user.employer_amoutjob = id.employer_amoutjob;

            db.Entry(user).State = EntityState.Modified;
            db.SaveChanges();
            return(Redirect("/Employer/HomeEmployer/Index"));
        }