コード例 #1
0
        public async Task <DataResponse <Event> > AddEmail([FromBody] DataInput <Participant> newParticipant)
        {
            try
            {
                var currentEvent = await _eventService.AddParticipant(newParticipant);

                var response = await _emailService.SendConfirmationEmail(newParticipant.Data.Email, currentEvent.Data.FirstOrDefault());

                var result = await _eventService.UpdateEvent(response.Data.FirstOrDefault());

                return(currentEvent);
            }
            catch (Exception ex)
            {
                LoggerHelper.Log(ex);
                return(new DataResponse <Event>()
                {
                    Errors = new Dictionary <string, List <string> >()
                    {
                        ["*"] = new List <string> {
                            ex.Message
                        },
                    },
                    Success = false
                });
            }
        }
コード例 #2
0
        public async Task <IActionResult> AddParticipant(AddParticipant newParticipant)
        {
            bool isAdded = await _eventService.AddParticipant(newParticipant.EventId, newParticipant.UserId);

            if (isAdded)
            {
                return(Ok(new { Status = "OK", Message = "Poprawnie dołączono do eventu" }));
            }
            return(Ok(new { Status = "Exists", Message = "Już jesteś zapisany na to wydażenie" }));
        }
コード例 #3
0
        public ActionResult <SuccessResponse> AddParticipant(EventParticipantAddRequest model)
        {
            int          code     = 200;
            BaseResponse response = null;

            try
            {
                int userId = _authService.GetCurrentUserId();
                _service.AddParticipant(model, userId);

                response = new SuccessResponse();
            }
            catch (Exception ex)
            {
                code     = 500;
                response = new ErrorResponse($"Generic Errors: { ex.Message}");
                base.Logger.LogError(ex.ToString());
            }

            return(StatusCode(code, response));
        }