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);
        }
示例#2
0
        public HttpResponseMessage UpdateJourney(int id, [FromBody] Journey journey)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _journeyProvider.SetEmail((string)HttpContext.Current.Items["email"]);
                    _journeyProvider.UpdateJourney(id, journey);
                    return(Request.CreateResponse(HttpStatusCode.OK, "Successfully updated!"));
                }

                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            catch (Exception exception)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception.Message));
            }
        }