internal Goal CreateGoal(Goal goal)
        {
            var team = _teamLogic.GetTeamForUser();

            var capability = _dimensionRepo.FindCapabilityById(goal.CapabilityId);
            if (capability == null)
            {
                throw new ApplicationException("Invalid capability Id.");
            }

            var newGoal = new Data.Goal()
            {
                Capabilty = capability,
                DueDate = goal.DueDate,
                Title = "New Goal",
                Description = goal.Notes,
                TeamId = team.Id
            };

            _goalRepository.CreateGoal(newGoal);
            _goalRepository.SaveChanges();

            return new Goal()
                {
                    Id = newGoal.Id,
                    DimensionId = newGoal.Capabilty.DimensionId,
                    DimensionText = newGoal.Capabilty.Dimension.Name,
                    CapabilityId = newGoal.CapabiltyId,
                    CapabilityText = newGoal.Capabilty.Description,
                    DueDate = newGoal.DueDate,
                    Notes = newGoal.Description,
                    Completed = newGoal.Completed
                };
        }
        public IHttpActionResult Post(Goal goal)
        {
            if (ModelState.IsValid)
            {
                var created = GoalLogic.CreateGoal(goal);

                string uri = Url.Link("Default", new { id = created.Id });

                return Created(uri, created);
            }
            else
            {
                return BadRequest(ModelState);
            }
        }
        internal void UpdateGoalById(int id, Goal goal)
        {
            var currentGoal = _goalRepository.GetGoalById(id);
            if(currentGoal != null)
            {
                currentGoal.Completed = goal.Completed;
                currentGoal.Description = goal.Notes;
                currentGoal.CapabiltyId = goal.CapabilityId;
                currentGoal.DueDate = goal.DueDate;

                _goalRepository.SaveChanges();
            }
            else
            {
                throw new ApplicationException("Invalid goal Id.");
            }
        }
 public IHttpActionResult Put(int id, Goal goal)
 {
     if (GoalLogic.GoalExists(id))
     {
         GoalLogic.UpdateGoalById(id, goal);
         return Content(HttpStatusCode.OK, GoalLogic.GetGoal(id));
     }
     else
     {
         return NotFound();
     }
 }