Example #1
0
        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 }));
        }
Example #2
0
 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);
 }
Example #3
0
 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));
         }
     }
 }
Example #4
0
        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);
        }
Example #5
0
        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();
        }
Example #7
0
 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));
         }
     }
 }
Example #8
0
        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());
        }
Example #9
0
 public WorkoutsController(FitnessContext context)
 {
     _context = context;
 }
Example #10
0
 public UsersController(FitnessContext context)
 {
     _context = context;
 }
Example #11
0
 public ExercisesController(FitnessContext db)
 {
     _db = db;
 }
Example #12
0
 public ProductRepository(FitnessContext context) : base(context)
 {
     _context = context;
 }
Example #13
0
 public EntryController(FitnessContext context)
 {
     _context = context;
 }
Example #14
0
 public OrderRepository(FitnessContext context) : base(context)
 {
     _context = context;
 }
 public MemberController(FitnessContext context)
 {
     _context = context;
 }
 public CustomerRepository(FitnessContext context) : base(context)
 {
     _context = context;
 }
Example #17
0
 public Repository(FitnessContext context)
 {
     _context = context;
 }
 public StatController(FitnessContext context)
 {
     _context = context;
 }
 public ExerciseRepository(FitnessContext context) : base(context)
 {
     _context = context;
 }
Example #20
0
 public SessionsController(FitnessContext context)
 {
     _context = context;
 }
Example #21
0
 public NoteController(FitnessContext context, IAuthRepository authRepository)
 {
     _context        = context;
     _authRepository = authRepository;
 }
Example #22
0
 public WorkoutTypeRepository(FitnessContext context) : base(context)
 {
 }
 public EmployeeRepository(FitnessContext context) : base(context)
 {
     _context = context;
 }
 public WorkoutProgramRepository(FitnessContext context) : base(context)
 {
     _context = context;
 }
Example #25
0
 private Service()
 {
     db = new FitnessContext();
 }