示例#1
0
        public IActionResult Get(int id)
        {
            var charityEvent = charityEventService.Get(id);

            if (charityEvent == null)
            {
                return(NotFound());
            }

            return(Ok(charityEvent));
        }
        public IActionResult AddEmailEventNotification([FromBody]SendEmailEventNotificationInputModel inputModel)
        {
            var charityEvent = _charityEventService.Get(inputModel.CharityEventId);
            string charityName = _charityService.GetCharityName(charityEvent.CharityId);

            foreach (var p in charityEvent.Participants)
            {
                if (p.IsAccepted != true)
                {
                    continue;
                }

                var user = _userService.GetUser(p.UserId);

                var sendEmailEventWasAddedModel = new SendEmailEventNotificationModel()
                {
                    EmailAddress = user.EmailAddress,
                    Content = inputModel.Content,
                    CharityEventName = charityEvent.Name,
                    CharityName = charityName,
                    Subject = inputModel.Subject
                };

                _emailNotificationService.SendEmailEventNotification(sendEmailEventWasAddedModel);
            }

            _charityEventService.AddEventNotification(inputModel);

            return Ok();
        }