public async Task <IHttpActionResult> StartTrainingSession() { Guid newSessionId = Guid.Empty; using (var db = new FitnessContext()) { var session = db.TrainingSessions.Create(); db.TrainingSessions.Add(session); await db.SaveChangesAsync(); } return(Ok(new { status = Progress.Started })); }
public UnitOfWork(FitnessContext context) { _context = context; CustomerRepository = new CustomerRepository(_context); EmployeeRepository = new EmployeeRepository(context); GymRepository = new GymRepository(context); OrderRepository = new OrderRepository(context); OrderItemRepository = new OrderItemRepository(context); ProductRepository = new ProductRepository(context); ExerciseRepository = new ExerciseRepository(context); WorkoutTypeRepository = new WorkoutTypeRepository(context); WorkoutRepository = new WorkoutRepository(context); WorkoutProgramRepository = new WorkoutProgramRepository(context); }
public ActionResult CreateUser() { using (var context = new FitnessContext()) { var result = queryManager.CreateUser(context, Request); if (result.Success) { return(View("MainScreen", activeUserManager.ActiveUser)); } else { return(View("Index", result.ErrorMessages)); } } }
public static Activity GetActivity(int actId) { var context = new FitnessContext(); //Display native SQL query in console for debugging purposes context.Database.Log = Console.Write; var userActivity = context.Activities .Include("ActivityType") .Where(a => a.Id == actId) .ToList(); var activity = userActivity[0]; return(activity); }
public async Task <IHttpActionResult> GetTrainingSession([FromUri] Guid sessionId) { using (var db = new FitnessContext()) { var session = await db.TrainingSessions.FirstOrDefaultAsync(x => x.Id == sessionId); var payload = new { SessionId = session.Id, Created = session.Date, Exercises = session.Sets.GroupBy(x => x.Exercise.Naming).Select(x => new { x.FirstOrDefault()?.Exercise.Naming, Sets = x.Count(), Reps = x.OrderBy(s => s.EndTime).Select(s => s.Repetitions).ToArray() }).ToArray() }; return(Ok(payload)); } }
static void Main(string[] args) { FitnessContext context = new FitnessContext(); Console.WriteLine("Disciplines;"); context.Disciplines.ToList() .ForEach(d => Console.WriteLine( d.Id + " " + d.Name)); //Count metoden undermineres af Lazy loading, så Console.WriteLine("\nFitnessClasses"); context.Classes.ToList().ForEach(fc => Console.WriteLine(fc + "\n\ttime: " + fc.Start.ToString() + "\n\tgym: " + fc.Gym + "\n\tusers: " + fc.Users?.Count)); Console.WriteLine("\nGyms"); context.Gyms.ToList().ForEach(g => Console.WriteLine(g.Id + " " + g.Location)); Console.WriteLine("\nInstructors"); context.Instructors.ToList().ForEach(i => Console.WriteLine(i.InstructorId + " " + i.Name + " \n\tdiscipliner:" + i.FitnessDiscipliner.Count + " \n\tclasses:" + i.Classes.Count)); Console.WriteLine("\nUsers"); context.Users.ToList().ForEach(u => Console.WriteLine(u.UserId + " " + u.Name)); Console.Read(); }
public ActionResult TryLogIn() { using (var context = new FitnessContext()) { User user; var validateResult = queryManager.ValidateLogOn(context, Request, out user); if (validateResult.Success) { Result LogOnResult = queryManager.TryLogIn(context, user, activeUserManager); if (LogOnResult.Success) { return(View("MainScreen", activeUserManager.ActiveUser)); } else { return(View("Index", validateResult.ErrorMessages)); } } else { return(View("Index", validateResult.ErrorMessages)); } } }
public async Task <IHttpActionResult> CreateTrainingSet([FromUri] Guid sessionId, [FromBody] TrainingSetModel set) { using (var db = new FitnessContext()) { var newSet = db.TrainingSets.Create(); var exercise = await db.Exercises.FirstOrDefaultAsync(x => x.Naming == set.Naming); var session = await db.TrainingSessions.FirstOrDefaultAsync(x => x.Id == sessionId); newSet.Exercise = exercise; newSet.TrainingSession = session; newSet.Repetitions = set.Repetitions; newSet.EndTime = DateTimeOffset.Now; newSet = db.TrainingSets.Add(newSet); await db.SaveChangesAsync(); } return(Ok()); }
public WorkoutsController(FitnessContext context) { _context = context; }
public UsersController(FitnessContext context) { _context = context; }
public ExercisesController(FitnessContext db) { _db = db; }
public ProductRepository(FitnessContext context) : base(context) { _context = context; }
public EntryController(FitnessContext context) { _context = context; }
public OrderRepository(FitnessContext context) : base(context) { _context = context; }
public MemberController(FitnessContext context) { _context = context; }
public CustomerRepository(FitnessContext context) : base(context) { _context = context; }
public Repository(FitnessContext context) { _context = context; }
public StatController(FitnessContext context) { _context = context; }
public ExerciseRepository(FitnessContext context) : base(context) { _context = context; }
public SessionsController(FitnessContext context) { _context = context; }
public NoteController(FitnessContext context, IAuthRepository authRepository) { _context = context; _authRepository = authRepository; }
public WorkoutTypeRepository(FitnessContext context) : base(context) { }
public EmployeeRepository(FitnessContext context) : base(context) { _context = context; }
public WorkoutProgramRepository(FitnessContext context) : base(context) { _context = context; }
private Service() { db = new FitnessContext(); }