Пример #1
0
        public ActionResult AddBio(int userId)
        {
            var model      = new MenteeBioModel();
            var categories = _user.GetCategories();

            model.Categories = GetSelectListItems(categories);

            //Get user by id and pass user to the view

            model.User = _user.GetUserById(userId);
            return(View(model));
        }
Пример #2
0
        public ActionResult AddBio(MenteeBioModel model, int userId)
        {
            //Get user by id
            var user = _user.GetUserById(userId);
            //Populate Category Dropdown List
            var categories = _user.GetCategories();

            model.Categories = GetSelectListItems(categories);

            if (ModelState.IsValid)
            {
                try
                {
                    //Map MenteeBio info to mentee table
                    var mentee = new MenteeModel
                    {
                        UserId   = user.UserId,
                        Address  = model.Address,
                        Birthday = model.Birthday,
                        Gender   = model.Gender,
                        MobileNo = model.MobileNo,
                        Bio      = model.Bio,
                        Category = model.Category
                    };

                    _mentee.AddMentee(mentee, user.UserId);
                    //Trying to log user in immediately after adding profile
                    var identity = user.GetUserIdentity();
                    AuthenticationManager.SignIn(identity);
                    return(RedirectToAction("index"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Invalid Reg", ex.Message);
                }
            }
            return(View(model));
        }