Ejemplo n.º 1
0
        /// <summary>
        /// Lightweight process to handle the creation of a match and sending of invites out at a later date!
        /// </summary>
        /// <param name="match">MatchDTO: a partial match!</param>
        /// <returns>the unique id of the match : or null</returns>
        public async Task <Guid?> CreateMatch(CreateMatchDTO match)
        {
            _Logger.LogInformation($"MatchManager: {HelperMethods.GetCallerMemberName()}");
            var generator = _MatchCreateFactory.GetBaseMatchCreator();

            return(await generator.Create(match));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateMatch([FromBody] CreateMatchDTO match)
        {
            _Logger.LogInformation($"Matches: {HelperMethods.GetCallerMemberName()}");
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var result = await Mediator.Send(new CreateMatchCommand()
                {
                    Match = match
                });

                if (result != null)
                {
                    return(CreatedAtRoute("GetMatchById", new { id = result }, match));
                }

                return(BadRequest("Save failed"));
            }
            catch (Exception ex)
            {
                _Logger.LogError($"Something went wrong at CreateMatchWithInvites action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Support the creation of a Match Record and trigger the invitation for all club members
        /// </summary>
        /// <param name="matchView"></param>
        public async Task <Guid?> CreateMatchWithInvites(CreateMatchDTO matchView)
        {
            _Logger.LogInformation($"MatchManager method: {HelperMethods.GetCallerMemberName()}");

            Guid?matchId = null;

            using (ExecutionPerformanceMonitor monitor = new ExecutionPerformanceMonitor(_Logger, "MatchManager"))
            {
                var match = _Mapper.Map <Match>(matchView);
                //Step1. Check if invites are needed to be added/created
                if (matchView.InviteActiveMembers)
                {
                    await GetAllMembersAndAddToInvites(match);
                }
                //StepX. Check if we need to email and then message it!
                if (matchView.SendInvites)
                {
                    //Now we need to send the invites then!
                    await CreateInvitationRequestAndPublish(match.Invites.ToList(), matchView.Date);

                    match.InvitesSent = true;
                }
                //StepX. Save the match! (N.B. here we might want to return the object!)
                matchId = await _Mediator.Send(new CreateMatchCommand()
                {
                    Match = match
                });

                //Not awaited to speed up performance!
                monitor.CreatePerformanceMetricAndLogEvent("CreateMatch");
            }
            return(matchId);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// TODO: lightweight process to handle the creation of a match and sending of invites out at a later date!
        /// </summary>
        /// <param name="match">MatchDTO: a partial match!</param>
        /// <returns>the unique of the match : or null!</returns>
        public async Task <Guid?> CreateMatch(CreateMatchDTO match)
        {
            _Logger.LogInformation($"MatchManager: {HelperMethods.GetCallerMemberName()}");

            Guid?matchId;
            var  mappedMatch = _Mapper.Map <Match>(match);

            //Save the match!
            matchId = await _Mediator.Send(new CreateMatchCommand()
            {
                Match = mappedMatch
            });

            return(matchId);
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> CreateMatch([FromBody] CreateMatchDTO match)
        {
            _Logger.LogInformation($"Matches: {HelperMethods.GetCallerMemberName()}");
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var record = await _MatchManager.CreateMatch(match);

            if (record != null)
            {
                return(CreatedAtRoute("GetMatchById", new { id = record }, match));
            }
            return(BadRequest("Save failed"));
        }