Exemplo n.º 1
0
        public async Task When(CreateWorkout cmd)
        {
            var workoutId   = new WorkoutId(cmd.Id);
            var challengeId = new ChallengeId(cmd.ChallengeId);

            await Update(workoutId, w => w.Create(workoutId, challengeId, new CoreDomain.Types.WorkoutType(cmd.WorkoutType), cmd.Repetitions));
        }
Exemplo n.º 2
0
        protected override void OnHandleIntent(Intent intent)
        {
            var bundle = intent.GetBundleExtra(nameof(CreateWorkout));
            var cmd    = new CreateWorkout(Guid.NewGuid(), new Guid(bundle.GetString(nameof(CreateWorkout.ChallengeId))), bundle.GetString(nameof(CreateWorkout.WorkoutType)), bundle.GetInt(nameof(CreateWorkout.Repetitions)));
            var task   = workoutService.ExecuteCommand(cmd);

            task.ContinueWith(_ => OnSuccess(cmd.Id));
            task.ContinueWith(_ => OnFailure());
        }
Exemplo n.º 3
0
        public Workout Post(CreateWorkout request)
        {
            //var workout = request.ConvertTo<Workout>();
            Workout workout = new Workout();

            workout.PlanId      = request.PlanId;
            workout.WorkoutDate = request.WorkoutDate;
            workout.Sport       = request.Sport;
            workout.Duration    = request.Duration;

            Db.Save(workout);
            return(workout);
        }
        public ActionResult <GymBuddyAPI.Models.WorkoutModel> PostWorkout(CreateWorkout workout)
        {
            var userName     = User.Claims.Single(a => a.Type == ClaimTypes.NameIdentifier).Value;
            var currentUsser = _context.UserData.First(i => i.User == userName);
            var insertValue  = new GymBuddyAPI.Entities.Workout()
            {
                WorkoutName = workout.Name,
                UserData    = currentUsser
            };

            var value = _context.Workouts.Add(insertValue);

            _context.SaveChanges();
            return(Ok(workout));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([FromBody] CreateWorkout model)
        {
            var workout = _mapper.Map <Workout>(model);

            try
            {
                await _workoutService.Create(workout);

                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }