Esempio n. 1
0
        public JsonResult ModifyInforJob(string nameJob, int salaryID, int positionId, List <int> idList)
        {
            var accID   = int.Parse(User.Identity.Name);
            var acc     = new AccountDao().FindAccountById(accID);
            var userNew = new User();

            userNew.DesiredJob    = nameJob;
            userNew.Salary        = salaryID;
            userNew.PositionApply = positionId;
            var check = new UserDao().ModifyUserJob(acc.UserId, userNew);

            if (!check)
            {
                return(Json(new
                {
                    status = false
                }));
            }
            for (var i = 0; i < idList.Count; i++)
            {
                var newUserMajor = new UserMajor();
                newUserMajor.UserID  = acc.UserId;
                newUserMajor.MajorID = idList[i];
                var checkStepSecond = new UserMajorDao().InsertUserMajor(newUserMajor);
                if (!checkStepSecond)
                {
                    check = false;
                    break;
                }
            }
            return(Json(new
            {
                status = check
            }));
        }
 public bool InsertUserMajor(UserMajor userMajor)
 {
     try
     {
         db.UserMajors.Add(userMajor);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Esempio n. 3
0
        public JsonResult CreateAccountInfor(Guid userID, string email, string name, string mobile, string dateBirth, string sex, string atSchool, int area, List <int> listJob)
        {
            var userInfor = new User();

            userInfor.UserId     = userID;
            userInfor.UserName   = name;
            userInfor.UserEmail  = email;
            userInfor.UserMobile = mobile;
            userInfor.AtSchool   = (atSchool == "in") ? true : false;
            userInfor.Sex        = sex;
            userInfor.UserArea   = area;
            string[] splitDate = dateBirth.Split('-');
            userInfor.UserBirthDay    = new DateTime(int.Parse(splitDate[0]), int.Parse(splitDate[1]), int.Parse(splitDate[2]));
            userInfor.CompleteProfile = 1;
            var checkInsertUser      = new UserDao().InsertUser(userInfor);
            var checkInsertUserMajor = true;

            foreach (int x in listJob)
            {
                var userMajor = new UserMajor();
                userMajor.UserID  = userID;
                userMajor.MajorID = x;
                var ck = new UserMajorDao().InsertUserMajor(userMajor);
                if (!ck)
                {
                    checkInsertUserMajor = ck;
                }
            }
            if (checkInsertUser && checkInsertUserMajor)
            {
                return(Json(new
                {
                    status = true
                }));
            }
            return(Json(new
            {
                status = false
            }));
        }
Esempio n. 4
0
        public JsonResult AddListUserSkill(List <int> listAdd, List <int> listParent)
        {
            var accID = int.Parse(User.Identity.Name);
            var acc   = new AccountDao().FindAccountById(accID);
            var check = true;
            var umDao = new UserMajorDao();

            for (var i = 0; i < listAdd.Count; i += 1)
            {
                var add = new UserMajor();
                add.UserID      = acc.UserId;
                add.MajorID     = listAdd[i];
                add.MajorParent = listParent[i];
                if (!umDao.InsertUserMajor(add))
                {
                    check = false;
                    break;
                }
            }
            return(Json(new
            {
                status = check
            }));
        }