Пример #1
0
        protected void BtnCheck_Click(object sender, EventArgs e)
        {
            List <CUserFocusArticle> list = new List <CUserFocusArticle>();
            UserFocus userfocus           = new UserFocus();
            string    userID = dpUser.SelectedValue.ToString();

            list = userfocus.GetAllUserFocusInfoByUserID(userID);
            GridView1.DataSource = list;
            GridView1.DataBind();
        }
        public ActionResult ChooseFocus(int id, UserFocus userfocus)
        {
            var userId     = User.Identity.GetUserId();
            var newSkillId = id;

            var thisUserFocuses = db.UserFocus.Where(user => user.UserId == userId).ToList();

            if (thisUserFocuses.Count >= 3)
            {
                return(RedirectToAction("SkillList"));
            }

            userfocus.SkillId = newSkillId;
            userfocus.UserId  = userId;
            userfocus.Year    = DateTime.Now.AddYears(1);

            db.UserFocus.Add(userfocus);
            db.SaveChanges();

            return(RedirectToAction("SkillList"));
        }