Beispiel #1
0
 public Skills(AddSkillViewModel model)
 {
     Name        = model.Name;
     Description = model.Description;
     Cost        = model.Cost;
     SkillId     = Guid.NewGuid();
 }
        public async Task <IActionResult> DeleteSkill([FromBody] AddSkillViewModel skill)
        {
            try
            {
                var userId = _userAppContext.CurrentUserId;
                var user   = await _userRepository.GetByIdAsync(userId);

                if (user != null)
                {
                    var findSkillItem = user.Skills.SingleOrDefault(x => x.Id == skill.Id);
                    if (findSkillItem != null)
                    {
                        findSkillItem.IsDeleted = true;
                        user.Skills[user.Skills.FindIndex(x => x.Id == skill.Id)] = findSkillItem;
                        await _userRepository.Update(user);

                        return(Json(new { Success = true }));
                    }
                    else
                    {
                        return(Json(new { Success = false, Message = "Can't find the language!" }));
                    }
                }
                else
                {
                    return(Json(new { Success = false, Message = "Can't find the user!" }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { Message = "error" }));
            }
        }
        public async Task <IActionResult> DeleteSkill([FromBody] AddSkillViewModel skill)
        {
            //Your code here;
            await _profileService.DeleteSkillAsync(skill);

            return(Json(new { Success = true }));
        }
Beispiel #4
0
 public async Task <IActionResult> UpdateSkill([FromBody] AddSkillViewModel skill)
 {
     try
     {
         if (ModelState.IsValid)
         {
             String id       = "";
             String talentId = String.IsNullOrWhiteSpace(id) ? _userAppContext.CurrentUserId : id;
             var    result   = _userRepository.GetByIdAsync(talentId).Result;
             if (skill.Id != null)
             {
                 var updateSkill = result.Skills.SingleOrDefault(x => x.Id == skill.Id);
                 {
                     updateSkill.Skill           = skill.Name;
                     updateSkill.ExperienceLevel = skill.Level;
                 }
                 await _userRepository.Update(result);
             }
             return(Json(new { Success = true }));
         }
         return(Json(new { Success = false }));
     }
     catch (Exception e)
     {
         return(Json(new { Success = false, e.Message }));
     }
 }
Beispiel #5
0
        public ActionResult AddSkill([FromBody] AddSkillViewModel skill)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    String id       = "";
                    String talentId = String.IsNullOrWhiteSpace(id) ? _userAppContext.CurrentUserId : id;
                    var    addSkill = new UserSkill
                    {
                        Id              = ObjectId.GenerateNewId().ToString(),
                        UserId          = _userAppContext.CurrentUserId,
                        Skill           = skill.Name,
                        ExperienceLevel = skill.Level,
                        IsDeleted       = false
                    };
                    var result = _userRepository.GetByIdAsync(talentId).Result;
                    result.Skills.Add(addSkill);
                    _userRepository.Update(result);
                    return(Json(new { Success = true }));
                }

                return(Json(new { Success = false }));
            }
            catch (Exception e)
            {
                return(Json(new { Success = false, e.Message }));
            }
        }
Beispiel #6
0
        public async Task <IActionResult> DeleteSkill([FromBody] AddSkillViewModel skill)
        {
            skill.IsDeleted = true;
            var id = await _profileService.AddUpdateSkill(skill);

            return(Json(new { Id = id }));
        }
Beispiel #7
0
 public SkillController(ISkillRepository skillRepository)
 {
     _showViewModel   = new ShowSkillViewModel();
     _addViewModel    = new AddSkillViewModel();
     _purposeModel    = new PurposeSkillViewModel();
     _skillRepository = skillRepository;
 }
        public async Task <bool> AddNewSkill(AddSkillViewModel skill)
        {
            try
            {
                var  userId      = _userAppContext.CurrentUserId;
                User userProfile = await _userRepository.GetByIdAsync(userId);

                if (userProfile == null)
                {
                    return(false);
                }

                var newSkill = new UserSkill
                {
                    Id        = ObjectId.GenerateNewId().ToString(),
                    IsDeleted = false,
                    UserId    = userId
                };
                UpdateSkillFromView(skill, newSkill);
                userProfile.Skills.Add(newSkill);
                await _userRepository.Update(userProfile);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public async Task <bool> UpdateSkill(AddSkillViewModel skill)
        {
            try
            {
                var  userId      = _userAppContext.CurrentUserId;
                User userProfile = await _userRepository.GetByIdAsync(userId);

                if (userProfile == null)
                {
                    return(false);
                }
                var orginalSkill = userProfile.Skills.SingleOrDefault(x => x.Id == skill.Id);
                if (orginalSkill == null)
                {
                    return(false);
                }
                UpdateSkillFromView(skill, orginalSkill);
                await _userRepository.Update(userProfile);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #10
0
        public IHttpActionResult Add(AddSkillViewModel model)
        {
            var jobSeeker = this.data.JobSeekerProfiles.All()
                .FirstOrDefault(x => x.UserId == this.CurrentUserId);

            if (jobSeeker == null)
            {
                return this.BadRequest("You must be a job seeker to add a skill");
            }

            if (model != null && ModelState.IsValid)
            {
                var skill = AutoMapper.Mapper.Map<Skill>(model);

                this.data.Skills.Add(skill);
                this.data.SaveChanges();

                model.Id = skill.Id;
                jobSeeker.Skills.Add(skill);

                this.data.SaveChanges();

                return this.Ok(model);
            }

            return this.BadRequest();
        }
Beispiel #11
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        /// <param name="model"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public virtual async Task <Skill> AddSkillAsync(AddSkillViewModel model, CancellationToken cancellationToken = default(CancellationToken))
        {
            var skills = _unitOfWork.Skills.Search();

            skills = skills.Where(x => x.Name.Equals(model.Name, StringComparison.InvariantCultureIgnoreCase));

            var skill = await skills.FirstOrDefaultAsync(cancellationToken);

            if (skill != null)
            {
                throw new HttpException((int)HttpStatusCode.Conflict, HttpMessages.SkillIsDuplicate);
            }

            //Inital skill object
            skill             = new Skill();
            skill.Name        = model.Name;
            skill.CreatedTime = DateTime.Now.ToOADate();

            //add skill to database
            _unitOfWork.Skills.Insert(skill);

            //save changes to database
            await _unitOfWork.CommitAsync();

            return(skill);
        }
        public async Task <IActionResult> DeleteSkill([FromBody] AddSkillViewModel delete_skill_model, String id = "")
        {
            String talentId = String.IsNullOrWhiteSpace(id) ? _userAppContext.CurrentUserId : id;

            //Console.WriteLine(talentId);

            //Your code here;
            if (talentId != null)
            {
                User existingTalent = (await _userRepository.GetByIdAsync(talentId));

                var newRSkills = new List <UserSkill>();

                foreach (var item in existingTalent.Skills)
                {
                    var delete_skill = existingTalent.Skills.SingleOrDefault(x => x.Id == delete_skill_model.Id);
                    // var skill = existingTalent.Skills.SingleOrDefault(x => x.Id == item.Id);
                    if (item.Id != delete_skill_model.Id)
                    {
                        newRSkills.Add(item);
                    }
                }
                existingTalent.Skills    = newRSkills;
                existingTalent.UpdatedBy = talentId;
                existingTalent.UpdatedOn = DateTime.Now;
                await _userRepository.Update(existingTalent);

                User UpdateTalent = (await _userRepository.GetByIdAsync(talentId));
                return(Json(new { success = true, data = existingTalent }));
            }


            return(Json(new { success = false }));
        }
Beispiel #13
0
        public AddSkill()
        {
            InitializeComponent();

            AddSkillViewModel addskillviewmodel = new AddSkillViewModel();

            this.DataContext = addskillviewmodel;
        }
Beispiel #14
0
        public async Task Insert(AddSkillViewModel model)
        {
            var skill = new Skills(model);

            Insert(skill);

            var users = await(new UserInfoRepository()).GetAll();

            _userSkillRepository.AddNewSkillToUsers(skill, users);
        }
        public AddSkillPage()
        {
            _viewModel           = new AddSkillViewModel();
            _viewModel.SkillItem = new Skill();
            _viewModel.SkillItem.SkillFirstObservation = _viewModel.Date = DateTime.Now;
            _viewModel.SkillItem.AccessLevel           = 0;

            InitializeComponent();
            BindingContext = _viewModel;
            ProgenyCollectionView.ItemsSource = _viewModel.ProgenyCollection;
        }
 // Nik custom code
 protected UserSkill SkillFromViewModel(AddSkillViewModel model)
 {
     return(new UserSkill
     {
         Id = model.Id,
         UserId = model.CurrentUserId,
         Skill = model.Name,
         ExperienceLevel = model.Level,
         IsDeleted = false,
     });
 }
Beispiel #17
0
        public IActionResult Index()
        {
            var addSkillViewModel = new AddSkillViewModel
            {
                SkillLevels     = jobSeekerService.GetSkillLevel(),
                Skills          = skillsService.GetAll(),
                JobSeekerSkills = jobSeekerService.GetJobSeekerSkills(HttpContext.Session.Get <string>("JobSeekerId"))
            };

            return(View(addSkillViewModel));
        }
Beispiel #18
0
        public IActionResult Add(AddSkillViewModel addSkillViewModel)
        {
            Skill newSkill = new Skill
            {
                Name = addSkillViewModel.Name
            };

            context.Skills.Add(newSkill);
            context.SaveChanges();

            return(Redirect("/"));
        }
Beispiel #19
0
        public JsonResult AddSkill(AddSkillViewModel vm)
        {
            var userSkill = new UserSkill
            {
                UserId  = WebUser.Id,
                SkillId = vm.SkillId,
            };

            _userSkillRepository.Create(userSkill);
            _unitOfWork.Commit();

            return(Json(true));
        }
Beispiel #20
0
        public ActionResult UpdateSkill(AddSkillViewModel skill)
        {
            var existingSkill = _personSkillRepository.GetById(skill.Id);

            if (existingSkill.PersonId != _appContext.LoginId)
            {
                return(new JsonCamelCaseResult(new { Success = false, Message = "You are not allowed to edit this skill" }, JsonRequestBehavior.AllowGet));
            }
            existingSkill.Skill           = skill.Name;
            existingSkill.ExperienceLevel = skill.Level;
            existingSkill.UpdatedOn       = DateTime.Now;
            existingSkill.UpdatedBy       = _appContext.LoginId;
            _personSkillRepository.Update(existingSkill);
            return(new JsonCamelCaseResult(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
Beispiel #21
0
        public IActionResult Add(AddSkillViewModel skill)
        {
            if (ModelState.IsValid)
            {
                context.Skills.Add(new Skill
                {
                    Name        = skill.Name,
                    Description = skill.Description
                });
                context.SaveChanges();
                return(Redirect("/Skill/"));
            }

            return(View("Add", skill));
        }
Beispiel #22
0
        public async Task <IActionResult> DeleteSkill([FromBody] AddSkillViewModel skill)
        {
            try
            {
                var sk = await _userSkillRepository.GetByIdAsync(skill.Id);

                await _userSkillRepository.Delete(sk);

                return(Json(new { Success = true }));
            }
            catch (Exception e)
            {
                return(Json(new { Success = false, message = e }));
            }
        }
        public async Task <IActionResult> DeleteSkill([FromBody] AddSkillViewModel skill)
        {
            String id       = " ";
            String talentId = String.IsNullOrWhiteSpace(id) ? _userAppContext.CurrentUserId : id;
            User   profile  = null;

            profile = (await _userRepository.GetByIdAsync(talentId));

            var skillelement = profile.Skills.SingleOrDefault(x => x.Id == skill.Id);
            {
                profile.Skills.Remove(skillelement);
                await _userRepository.Update(profile);

                return(Json(new { Success = true }));
            }
        }
        public bool AddNewSkill(AddSkillViewModel skill)
        {
            //Your code here;
            // TODO: Add new skill in service
            try
            {
                _userSkillRepository.Add(SkillFromViewModel(skill));
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw e;
            }
        }
        public async Task <IActionResult> DeleteSkill([FromBody] AddSkillViewModel skill)
        {
            //Your code here;
            var skillSearch = _userSkillRepository.Collection.FirstOrDefault(x => x.Id == skill.Id);

            if (skillSearch != null)
            {
                await _userSkillRepository.Delete(skillSearch);

                return(Json(new { message = "data is deleted" }));
            }
            else
            {
                return(Json(new { message = "data not found" }));
            }
        }
        public async Task <IActionResult> findSkills([FromBody] AddSkillViewModel skill)
        {
            //Your code here;

            var skillfind = await _userSkillRepository.FindAsync(x => x.Id == skill.Id);

            if (skillfind != null)
            {
                return(Json(new { data = skillfind }));
            }
            else
            {
                return(Json(new { message = "data not exist" }));
            }
            //throw new NotImplementedException();
        }
Beispiel #27
0
        public async Task <IActionResult> DeleteSkill([FromBody] AddSkillViewModel skill)
        {
            try
            {
                var mySkill = await _userSkillRepository.GetByIdAsync(skill.Id);

                mySkill.IsDeleted = true;
                await _userSkillRepository.Delete(mySkill);

                return(Json(new { Success = true, Message = "skill deleted succesfully" }));
            }
            catch
            {
                return(Json(new { Success = false, Message = "Error while deleting skill" }));
            }
        }
        public async Task <bool> UpdateSkillAsync(AddSkillViewModel skill)
        {
            //Your code here;
            // TODO: Update skill in service
            try
            {
                await _userSkillRepository.Update(SkillFromViewModel(skill));

                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw e;
            }
        }
        public async Task <IHttpActionResult> AddSkill(AddSkillViewModel model)
        {
            if (model == null)
            {
                model = new AddSkillViewModel();
                Validate(model);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var skill = await _skillService.AddSkillAsync(model, CancellationToken.None);

            return(Ok(skill));
        }
        public async Task <IActionResult> DeleteSkill([FromBody] AddSkillViewModel skill)
        {
            //Your code here;
            //throw new NotImplementedException();
            //try
            //{
            //    var dlSkill = await _userSkillRepository.GetByIdAsync(skill.Id);
            //    dlSkill.IsDeleted = true;
            //    await _userSkillRepository.Delete(dlSkill);
            //    return Json(new { Success = true, Message = "The Skill is succesfully deleted" });
            //}
            //catch
            //{
            //    return Json(new { Success = false, Message = "Error in deleting skill" });
            //}
            try
            {
                var userId = _userAppContext.CurrentUserId;
                var dUser  = await _userRepository.GetByIdAsync(userId);

                if (dUser != null)
                {
                    var findSkillItem = dUser.Skills.SingleOrDefault(x => x.Id == skill.Id);
                    if (findSkillItem != null)
                    {
                        findSkillItem.IsDeleted = true;
                        dUser.Skills[dUser.Skills.FindIndex(x => x.Id == skill.Id)] = findSkillItem;
                        await _userRepository.Update(dUser);

                        return(Json(new { Success = true }));
                    }
                    else
                    {
                        return(Json(new { Success = false, Message = "The Skill is not existing" }));
                    }
                }
                else
                {
                    return(Json(new { Success = false, Message = "The user is not existing" }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { Message = "Error in deleting" }));
            }
        }
        public async Task <IActionResult> UpdateSkill([FromBody] AddSkillViewModel skill)
        {
            try
            {
                var result = await _profileService.UpdateSkill(skill);

                if (result == false)
                {
                    return(Json(new { Success = false, data = "can not update the skill." }));
                }
                return(Json(new { Success = true, data = "update the skill successful." }));
            }
            catch (Exception e)
            {
                return(Json(new { Success = false, data = "error" }));
            }
        }