Ejemplo n.º 1
0
        public IActionResult CreatNewSkill(UserResumeViewModel model)
        {
            var appUserId = _userManager.GetUserId(User);
            var skilCount = _skillRepo.ReadAll(appUserId).Count();
            var maxLimit  = _config.GetValue <int>("SkillDBLimits:MaxSkillLimit");

            if (skilCount >= maxLimit)
            {
                // Response.StatusCode = 400; // THIS WILL STOP FORM AJAX TO UPDATE THE DIV TO DISPLAY MODEL ERRORS
                ModelState.AddModelError("", $"You have reached the max limit of proficiencies({maxLimit}), please delete unnecessary proficiencies ");
                return(ViewComponent("SkillsContainerEditing", new { appUserId = appUserId }));
            }

            if (!ModelState.IsValid)
            {
                //  Response.StatusCode = 400; //THIS WILL STOP FORM AJAX TO UPDATE THE DIV TO DISPLAY MODEL ERRORS
                return(ViewComponent("SkillsContainerEditing", new { appUserId = appUserId }));
            }

            var newSkill = new Skill()
            {
                Id = Guid.NewGuid(),
                ApplicationUserId = appUserId,
                TagName           = model.NewSkillViewModel.TagName,
                Level             = model.NewSkillViewModel.Level
            };

            _skillRepo.Create(newSkill);

            return(ViewComponent("SkillsContainerEditing", new { appUserId = appUserId }));
        }
Ejemplo n.º 2
0
        public IActionResult UserResume(string id)
        {
            var userInfo = _userInfoRepo.Read(id);

            if (userInfo == null)
            {
                Response.StatusCode  = 404;
                ViewBag.ErrorTitle   = "Can't find User";
                ViewBag.ErrorMessage = "The id did not match with any users in our data base";
                return(View("PageNotFound"));
            }

            var userID       = _userManager.GetUserId(User);
            var allUserItems = _achievementRepo.ReadAll(userInfo.UserInformationId);

            var model = new UserResumeViewModel
            {
                AppUserId         = userID,
                UserInfo          = userInfo,
                Achievements      = allUserItems,
                NewSkillViewModel = new SkillViewModel()
            };

            if (userID == id)
            {
                model.EnableOwnerOptions = true;
            }
            else
            {
                model.EnableOwnerOptions = false;
            }

            model.DefaultAvatarImage  = _config.GetValue <string>("FileUploadSettings:DefaultAvatarImgFilePath");
            model.DefaultGalleryImage = _config.GetValue <string>("FileUploadSettings:DefaultGalleryImgFilePath");

            return(View(model));
        }