Esempio n. 1
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);
        }
Esempio n. 2
0
 private Task SignUpRunner(Domain.Entities.MarathonSignUp marathonSignUp)
 {
     _context.Add(marathonSignUp);
     return(_context.SaveChangesAsync());
 }