public UserJourney StartJourney(int id)
        {
            _journeyProvider.SetEmail((string)HttpContext.Current.Items["email"]);
            _userActionPointProvider.SetEmail((string)HttpContext.Current.Items["email"]);
            _userSkillProvider.SetEmail((string)HttpContext.Current.Items["email"]);
            UserJourney userJourney = new UserJourney();
            Journey     refJourney  = _journeyProvider.GetJourney(id);

            userJourney.Title           = refJourney.Title;
            userJourney.Description     = refJourney.Description;
            userJourney.Level           = refJourney.Level;
            userJourney.Rating          = 0;
            userJourney.AverageDuration = refJourney.AverageDuration;
            userJourney.StartDate       = DateTime.Now;
            userJourney.DueDate         = DateTime.Now.AddYears(1);
            userJourney.Trainee         = Email;
            userJourney.Review          = "No review";
            userJourney.JourneyRef      = refJourney;
            userJourney.Coach           = refJourney.Coach;
            userJourney.Status          = UserJourneyStatus.InProgress;
            userJourney.Skills          = ConvertSkillsToUserSkills(refJourney.Skills);
            var userJourneyId = _repo.Add(ConvertToListItem(userJourney), ListNames.USER_JOURNEYS_LIST).Id;

            userJourney.Id = userJourneyId;
            return(userJourney);
        }
Exemplo n.º 2
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));
     }
 }