// PUT api/Activity/5 public IHttpActionResult Put(Activity activity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } try { return Ok(AL.Update(activity)); } catch (DbUpdateConcurrencyException) { if (!AL.ActivityExists(activity.Id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult Test(string id, Activity activity) { Account account = accounts.Get(id); var data = RandomForestModel.wrapRow(0, "", "", DateTime.Now, (double)account.Height * 0.0254, (double)account.Weight * 0.4536, activity.Duration.TotalSeconds, activity.Distance, activity.Steps, ""); ActivityType result = ActivityType.Walking; string name = logic.ApplyTree(data); if (name == "R") { result = ActivityType.Running; } else if (name == "W") { result = ActivityType.Walking; } else if (name == "J") { result = ActivityType.Jogging; } else if (name == "B") { result = ActivityType.Biking; } return Ok(result); }
public IHttpActionResult Post(Activity activity) { Activity Created = AL.Create(activity); List<Goal> goals = gLogic.UpdateCurrentGoals(Created.Id); List<Attainment> att = attLogic.GetNewAttainments(Created.Id); // Have to break up the tuple because the serializer on the server // differs from the deserializer on the phone. return Ok(new { Item1 = Created, Item2 = goals, Item3 = att }); }
public void ActivityLogic() { Mock<IUnitOfWork> uow = new Mock<IUnitOfWork>(); Mock<IActivityRepository> repo = new Mock<IActivityRepository>(); Mock<ITeamLogic> teamLogic = new Mock<ITeamLogic>(); ActivityLogic logic = new ActivityLogic(uow.Object, repo.Object, teamLogic.Object); var activity = new Activity(); var sequence = new MockSequence(); repo.InSequence(sequence).Setup(r => r.Create(activity)); repo.InSequence(sequence).Setup(r => r.Update(activity)); repo.InSequence(sequence).Setup(r => r.Get(activity.Id)); repo.InSequence(sequence).Setup(r => r.Delete(activity.Id)); logic.Create(activity); logic.Update(activity); logic.Get(activity.Id); logic.Delete(activity.Id); }
public void ActivityRepository() { Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>(); Mock<DbSet<Activity>> dbSet = new Mock<DbSet<Activity>>(); factory.Setup(m => m.CreateDbSet<Activity>()).Returns(dbSet.Object); ActivityRepository repo = new ActivityRepository(factory.Object); var activity = new Activity(); var sequence = new MockSequence(); dbSet.InSequence(sequence).Setup(e => e.Add(activity)); dbSet.InSequence(sequence).Setup(e => e.Find(activity.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(activity.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(activity.Id)); repo.Create(activity); repo.Get(activity.Id); repo.Update(activity); repo.Delete(activity.Id); }
public Activity Update(Activity activity) { Repo.Update(activity); Unit.SaveChanges(); return activity; }