public Goal Update(Goal goal)
        {
            Repo.Update(goal);
            Unit.SaveChanges();
            return goal;

        }
        // PUT api/Activity/5
        public IHttpActionResult Put(Goal goal)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                return Ok(Logic.Update(goal));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Logic.Exists(goal.Id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
 public IHttpActionResult Post(Goal goal)
 {
     if (!ModelState.IsValid)
     {
         BadRequest(ModelState);
     }
     Goal Created = Logic.Create(goal);
     return Ok(Created);
 }
        public void GoalRepository()
        {
            Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>();
            Mock<DbSet<Goal>> dbSet = new Mock<DbSet<Goal>>();

            factory.Setup(m => m.CreateDbSet<Goal>()).Returns(dbSet.Object);

            GoalRepository repo = new GoalRepository(factory.Object);

            var Goal = new Goal();

            var sequence = new MockSequence();
            dbSet.InSequence(sequence).Setup(e => e.Add(Goal));
            dbSet.InSequence(sequence).Setup(e => e.Find(Goal.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Goal.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Goal.Id));
            repo.Create(Goal);
            repo.Get(Goal.Id);
            repo.Update(Goal);
            repo.Delete(Goal.Id);
        }
        public void GoalLogic()
        {
            Mock<IUnitOfWork> uow = new Mock<IUnitOfWork>();
            Mock<IGoalRepository> repo = new Mock<IGoalRepository>();
            Mock<ITargetRepository> targetRepo = new Mock<ITargetRepository>();
            Mock<IActivityRepository> activityRepo = new Mock<IActivityRepository>();

            GoalLogic logic = new GoalLogic(uow.Object, repo.Object, targetRepo.Object, activityRepo.Object);

            var goal = new Goal();
            var sequence = new MockSequence();
            repo.InSequence(sequence).Setup(r => r.Create(goal));
            repo.InSequence(sequence).Setup(r => r.Update(goal));
            repo.InSequence(sequence).Setup(r => r.Get(goal.Id));
            repo.InSequence(sequence).Setup(r => r.Delete(goal.Id));
            logic.Create(goal);
            logic.Update(goal);
            logic.Get(goal.Id);
            logic.Delete(goal.Id);
        }
 public Goal Create(Goal goal)
 {
     goal = Repo.Create(goal);
     Unit.SaveChanges();
     return goal;
 }