public ActionResult ValidateUpdate(String first_name, String last_name, String sex, String avatar, String birthday, String email, String phone, String idcard, String address, String decsription)
 {
     if (HttpContext.Session["userID"] == null)
     {
         TempData["Message"] = "Vui lòng đăng nhập tài khoản ";
         return(RedirectToAction("DangNhap", "FrontEnd"));
     }
     else
     {
         int     userID     = Convert.ToInt32(HttpContext.Session["userID"]);
         PROFILE getProfile = db.PROFILEs.Find(userID);
         getProfile.ADDRESS         = address;
         getProfile.SEX             = sex;
         getProfile.IDENTITY_CARD   = idcard;
         getProfile.LAST_NAME       = last_name;
         getProfile.FIRST_NAME      = first_name;
         getProfile.AVATAR          = avatar;
         getProfile.BIRTHDAY        = birthday;
         getProfile.EMAIL           = email;
         getProfile.PHONE           = Convert.ToInt32(phone);
         getProfile.DESCRIPTION     = decsription;
         db.Entry(getProfile).State = EntityState.Modified;
         db.SaveChanges();
         TempData["Message"] = "Cập nhập thành công hồ sơ";
         return(RedirectToAction("Profile", "CV"));
     }
 }
Пример #2
0
        public ActionResult Create([Bind(Include = "PROFILE_ID,FIRST_NAME,LAST_NAME,IDENTITY_CARD,BIRTHDAY,SEX,EMAIL,PHONE,TOWN_ID,ADDRESS,AVATAR,DESCRIPTION")] PROFILE pROFILE)
        {
            if (ModelState.IsValid)
            {
                db.PROFILEs.Add(pROFILE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TOWN_ID = new SelectList(db.TOWNs, "TOWN_ID", "TOWN_NAME", pROFILE.TOWN_ID);
            return(View(pROFILE));
        }
        public ActionResult Create([Bind(Include = "RECUMENT_ID,EMPLOYER_ID,EMPLOYEE_AMOUNT,JOB_ID,START_DATE,WORK_MONTH_AMOUNT,CREATED_DATE,APPROVAL_DEADLINE,REFERRAL_WAGE_COST,RECUMENT_STATUS")] JOB_RECUMENT jOB_RECUMENT)
        {
            if (ModelState.IsValid)
            {
                db.JOB_RECUMENT.Add(jOB_RECUMENT);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.JOB_ID      = new SelectList(db.JOBs, "JOB_ID", "JOB_CODE", jOB_RECUMENT.JOB_ID);
            ViewBag.EMPLOYER_ID = new SelectList(db.PROFILEs, "PROFILE_ID", "FIRST_NAME", jOB_RECUMENT.EMPLOYER_ID);
            return(View(jOB_RECUMENT));
        }
        public ActionResult Create([Bind(Include = "CATEGORY_ID,JOB_CODE,JOB_NAME,MINIMUM_WAGE,MAXIMUM_WAGE,TOWN_ID,JOB_REQUIREMENT,JOB_DESCRIPTION,SHIFT_WORK")] JOB jOB)
        {
            if (ModelState.IsValid)
            {
                db.JOBs.Add(jOB);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CATEGORY_ID = new SelectList(db.JOB_CATEGORY, "CATEGORY_ID", "CATEGORY_NAME", jOB.CATEGORY_ID);
            ViewBag.SHIFT_WORK  = new SelectList(db.SHIFT_WORK_SCHEDULE, "SHIFT_ID", "SHIFT_ID", jOB.SHIFT_WORK);
            ViewBag.PROVINCE_ID = new SelectList(db.PROVINCEs, "PROVINCE_ID", "PROVINCE_NAME", jOB.TOWN.PROVINCE_ID);
            ViewBag.TOWN_ID     = new SelectList(db.TOWNs, "TOWN_ID", "TOWN_NAME", jOB.TOWN_ID);
            return(View(jOB));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "USERNAME,PASSWORD,ROLE_ID,FACEBOOK_ID,GMAIL_ID,RESET_TOKEN")] USER uSER)
        {
            uSER.USER_STATUS = 1;

            DateTime dateTime = DateTime.UtcNow.Date;

            uSER.JOINED_DATE   = dateTime.ToString("MM/dd/yyyy");
            uSER.PASSWORDAGAIN = uSER.PASSWORD;


            var generateID = (from user in db.USERs
                              orderby user.USER_ID descending
                              select user.USER_ID).Take(1).SingleOrDefault();

            if (uSER.FACEBOOK_ID == null)
            {
                uSER.FACEBOOK_ID = Convert.ToString(generateID + 1);
            }
            if (uSER.GMAIL_ID == null)
            {
                uSER.GMAIL_ID = Convert.ToString(generateID + 1);
            }

            PROFILE newProfile = new PROFILE();

            db.PROFILEs.Add(newProfile);
            try
            {
                db.USERs.Add(uSER);
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var errors in ex.EntityValidationErrors)
                {
                    foreach (var validationError in errors.ValidationErrors)
                    {
                        // get the error message
                        string errorMessage = validationError.ErrorMessage;
                        Debug.WriteLine(errorMessage);
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Пример #6
0
 public ActionResult ApplyJob(String userID, String recumentID)
 {
     using (var DBTransactions = db.Database.BeginTransaction())
     {
         try
         {
             JOB_RECUMENT_PROCESSING newProcessing = new JOB_RECUMENT_PROCESSING();
             newProcessing.RECUMENT_ID = Convert.ToInt32(recumentID);
             newProcessing.EMPLOYEE_ID = Convert.ToInt32(userID);
             DateTime dateTime = DateTime.UtcNow.Date;
             newProcessing.APPLYING_DATE       = dateTime.ToString("dd/NN/yyyy");
             newProcessing.APPROVAL_STATUS     = false;
             newProcessing.JOB_STATUS          = Convert.ToInt32(1);
             newProcessing.WAGE_PAYMENT_STATUS = Convert.ToInt32(0);
             // tao xong user , tien hanh tao profile
             db.JOB_RECUMENT_PROCESSING.Add(newProcessing);
             db.SaveChanges();
             DBTransactions.Commit();
             TempData["Message"] = "Bạn đã ứng tuyển thành công !";
             return(RedirectToAction("TrangChu", "FrontEnd"));
         }
         catch (System.Data.Entity.Infrastructure.DbUpdateException db)
         {
             Debug.WriteLine(db.ToString());
             DBTransactions.Rollback();
             TempData["Message"] = "Bạn đã ứng tuyển công việc này rồi";
             return(RedirectToAction("TrangChu", "FrontEnd"));
         }
         catch (Exception e)
         {
             Debug.WriteLine(e.ToString());
             DBTransactions.Rollback();
             TempData["Message"] = "Có lỗi xảy ra trong hệ thống, vui lòng thử lại sau";
             return(RedirectToAction("TrangChu", "FrontEnd"));
         }
     }
 }
        public bool dangKyUserFacebook(string facebookID, Dictionary <string, string> fbInfo)
        {
            using (var DBEntities = new PartTimeJobEntitiesEntities())
            {
                using (var DBTransactions = DBEntities.Database.BeginTransaction())
                {
                    try
                    {
                        USER newUser    = new USER();
                        var  generateID = (from user in DBEntities.USERs
                                           orderby user.USER_ID descending
                                           select user.USER_ID).Take(1).SingleOrDefault();

                        newUser.FACEBOOK_ID   = facebookID;
                        newUser.USERNAME      = facebookID + (generateID + 1);
                        newUser.PASSWORD      = facebookID + "2019group21dotnetNLUHashing";
                        newUser.PASSWORDAGAIN = facebookID + "2019group21dotnetNLUHashing";
                        DateTime dateTime = DateTime.UtcNow.Date;
                        newUser.JOINED_DATE = dateTime.ToString("MM/dd/yyyy");
                        newUser.GMAIL_ID    = Convert.ToString(generateID + 1);
                        newUser.USER_STATUS = (byte)1;
                        newUser.ROLE_ID     = byte.Parse(fbInfo["roleID"]);
                        DBEntities.USERs.Add(newUser);

                        // tao xong user , tien hanh tao profile
                        PROFILE newProfile = new PROFILE();
                        newProfile.FIRST_NAME = fbInfo["fbFirstName"];
                        newProfile.LAST_NAME  = fbInfo["fbLastName"];
                        newProfile.ADDRESS    = fbInfo["fbHometown"];
                        newProfile.BIRTHDAY   = fbInfo["fbBirthday"];
                        newProfile.EMAIL      = fbInfo["fbEmail"];
                        newProfile.SEX        = fbInfo["fbGender"];
                        DBEntities.PROFILEs.Add(newProfile);
                        DBEntities.SaveChanges();
                        DBTransactions.Commit();
                        return(true);
                    }
                    catch (Exception)
                    {
                        DBTransactions.Rollback();
                        DBEntities.Database.ExecuteSqlCommand("USE PartTimeJob;DECLARE @lastIdent int;SET @lastIdent = (SELECT TOP 1 USER_ID FROM[USER] ORDER BY USER_ID DESC);IF @lastIdent IS NULL BEGIN SET @lastIdent=1;END;DBCC CHECKIDENT('dbo.USER',RESEED,@lastIdent);");
                        DBEntities.Database.ExecuteSqlCommand("USE PartTimeJob;DECLARE @lastIdent int;SET @lastIdent = (SELECT TOP 1 PROFILE_ID FROM[PROFILE] ORDER BY PROFILE_ID DESC);IF @lastIdent IS NULL BEGIN SET @lastIdent=1;END;DBCC CHECKIDENT('dbo.PROFILE',RESEED,@lastIdent);");
                        return(false);
                    }
                }
            }
        }
        public ActionResult XacThucDangKy(USER model)
        {
            {
                if (!ModelState.IsValid)
                {
                    ViewBag.PreviousPage       = "Trang Chủ";
                    ViewBag.PreviousAction     = "TrangChu";
                    ViewBag.PreviousController = "FrontEnd";
                    using (var DBEntities = new PartTimeJobEntitiesEntities())
                    {
                        List <ROLE> roleList = (from role in DBEntities.ROLEs
                                                where role.ROLE_ID == 2 || role.ROLE_ID == 3
                                                select role).ToList();
                        SelectList resultList = new SelectList(roleList, "ROLE_ID", "ROLE_NAME");
                        ViewBag.RoleList = resultList;
                        return(View("DangKy", model));
                    }
                }
                else
                {
                    using (var DBEntities = new PartTimeJobEntitiesEntities())
                    {
                        using (var DBTransactions = DBEntities.Database.BeginTransaction())
                        {
                            USER getUser = (from user in DBEntities.USERs
                                            where user.USERNAME == model.USERNAME
                                            select user).FirstOrDefault <USER>();
                            if (getUser != null)
                            {
                                ViewBag.PreviousPage       = "Trang Chủ";
                                ViewBag.PreviousAction     = "TrangChu";
                                ViewBag.PreviousController = "FrontEnd";
                                List <ROLE> roleList = (from role in DBEntities.ROLEs
                                                        where role.ROLE_ID == 2 || role.ROLE_ID == 3
                                                        select role).ToList();
                                SelectList resultList = new SelectList(roleList, "ROLE_ID", "ROLE_NAME");
                                ViewBag.RoleList      = resultList;
                                ViewBag.UsernameError = "Tài khoản này đã có người sử dụng";
                                return(View("DangKy", model));
                            }
                            else
                            {
                                try
                                {
                                    USER newUser    = model;
                                    var  generateID = (from user in DBEntities.USERs
                                                       orderby user.USER_ID descending
                                                       select user.USER_ID).Take(1).SingleOrDefault();

                                    newUser.FACEBOOK_ID = Convert.ToString(generateID + 1);
                                    newUser.GMAIL_ID    = Convert.ToString(generateID + 1);
                                    newUser.USER_STATUS = (byte)1;
                                    DateTime dateTime = DateTime.UtcNow.Date;
                                    newUser.JOINED_DATE = dateTime.ToString("MM/dd/yyyy");
                                    DBEntities.USERs.Add(newUser);

                                    // tao xong user , tien hanh tao profile
                                    PROFILE newProfile = new PROFILE();
                                    DBEntities.PROFILEs.Add(newProfile);
                                    DBEntities.SaveChanges();
                                    DBTransactions.Commit();
                                    TempData["Message"] = "Chúc mừng tài khoản " + newUser.USERNAME + " đã đăng ký thành công !";
                                    return(RedirectToAction("TrangChu", "FrontEnd"));
                                }catch (Exception)
                                {
                                    DBTransactions.Rollback();
                                    DBEntities.Database.ExecuteSqlCommand("USE PartTimeJob;DECLARE @lastIdent int;SET @lastIdent = (SELECT TOP 1 USER_ID FROM[USER] ORDER BY USER_ID DESC);IF @lastIdent IS NULL BEGIN SET @lastIdent=1;END;DBCC CHECKIDENT('dbo.USER',RESEED,@lastIdent);");
                                    DBEntities.Database.ExecuteSqlCommand("USE PartTimeJob;DECLARE @lastIdent int;SET @lastIdent = (SELECT TOP 1 PROFILE_ID FROM[PROFILE] ORDER BY PROFILE_ID DESC);IF @lastIdent IS NULL BEGIN SET @lastIdent=1;END;DBCC CHECKIDENT('dbo.PROFILE',RESEED,@lastIdent);");
                                    TempData["Message"] = "Có lỗi xảy ra trong hệ thống, vui lòng thử lại sau";
                                    return(RedirectToAction("TrangChu", "FrontEnd"));
                                }
                            }
                        }
                    }
                }
            }
        }