Ejemplo n.º 1
0
        public async Task <IActionResult> SignUp([FromBody] MarathonSignUp signUpCredentials)
        {
            if (signUpCredentials == null)
            {
                return(BadRequest());
            }

            try
            {
                int marathonSignUpId = await _marathonService.SignUp(signUpCredentials);

                return(Ok(marathonSignUpId));
            }
            catch
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 2
0
        public async Task <int> SignUp(MarathonSignUp signUpCredentials)
        {
            var marathonSignUp = new Domain.Entities.MarathonSignUp
            {
                RunnerId          = signUpCredentials.RunnerId,
                SignUpDate        = DateTime.UtcNow,
                RaceKitOptionId   = signUpCredentials.RaceKitOptionId,
                SignUpStatusId    = SignUpStatus.SignedUp.Id,
                Cost              = signUpCredentials.Cost,
                CharityId         = signUpCredentials.CharityId,
                SponsorshipTarget = signUpCredentials.SponsorshipTarget
            };

            try
            {
                SignUpRunner(marathonSignUp)
                .Wait();
            }
            catch
            {
                throw new Exception("Error has given when created a marathon sign up record");
            }


            try
            {
                SignUpRunnerToEvents(marathonSignUp.Id, GetEventsByEventType(signUpCredentials.EventTypeId))
                .Wait();
            }
            catch
            {
                await RemoveMarathonSignUp(marathonSignUp.Id).ContinueWith(x => throw new Exception("Error has given when signed up runner to events"));
            }

            return(marathonSignUp.Id);
        }
Ejemplo n.º 3
0
        public Task <int> SignUp(MarathonSignUp signUpCredentials)
        {
            var uri = UriHelper.CombineUri(GlobalSettings.Instance.SignUpToMarathon);

            return(_requestProvider.PostAsync <MarathonSignUp, int>(uri, signUpCredentials, this.GetToken()));
        }