Example #1
0
 public HttpResponseMessage Post([FromBody] UserActionPoint userActionPoint)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _userActionPointProvider.SetEmail((string)HttpContext.Current.Items["email"]);
             return(Request.CreateResponse(HttpStatusCode.OK, _userActionPointProvider.AddUserActionPoint(userActionPoint)));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.InternalServerError, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
        private List <UserSkill> ConvertSkillsToUserSkills(List <Skill> skills)
        {
            var lookupValuesSkills = new List <UserSkill>();

            foreach (Skill skill in skills)
            {
                UserSkill userSkill        = new UserSkill();
                var       actionPoints     = skill.ActionPoints;
                var       subSkills        = skill.SubSkills;
                var       userActionPoints = new List <UserActionPoint>();
                foreach (ActionPoint ap in actionPoints)
                {
                    var uAp = new UserActionPoint
                    {
                        Title       = ap.Title,
                        Resources   = ap.Resources,
                        Status      = ItemStatus.InProgress,
                        Description = ap.Description
                    };

                    uAp = _userActionPointProvider.AddUserActionPoint(uAp);
                    userActionPoints.Add(uAp);
                }

                var userSkills = ConvertSkillsToUserSkills(subSkills);
                userSkill.Title        = skill.Title;
                userSkill.Status       = ItemStatus.InProgress;
                userSkill.Level        = skill.Level;
                userSkill.SubSkills    = userSkills;
                userSkill.ActionPoints = userActionPoints;
                userSkill.Description  = skill.Description;
                userSkill.Id           = _userSkillProvider.AddUserSkill(userSkill).Id;
                lookupValuesSkills.Add(userSkill);
            }

            return(lookupValuesSkills);
        }