示例#1
0
        public async Task <IActionResult> UpdateEvent(Guid eventId, [FromBody] UpdateEventRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var @event = await EventRepositoryRead.GetById(eventId).ConfigureAwait(false);

            if (@event == null)
            {
                return(NotFound("Event not found with id " + eventId));
            }

            // TODO: Move this into EventService

            @event.Location     = request.Location;
            @event.Name         = request.Name;
            @event.OtherDetails = request.OtherDetails;
            @event.RsvpOpen     = request.RsvpOpen;
            @event.TimeZoneId   = request.TimeZoneId;
            @event.Form.Clear();
            foreach (var prompt in request.Form)
            {
                if (prompt.Id == Guid.Empty)
                {
                    prompt.Id = Guid.NewGuid(); //TODO - move to EventService
                }

                @event.Form.Add(prompt);
            }

            if (request.RsvpClosesAtLocal.HasValue)
            {
                request.RsvpClosesAtLocal.Value.TryConvertToUtc(request.TimeZoneId, out var rsvpClosesAtUtc);
                @event.RsvpClosesAtUtc = rsvpClosesAtUtc;
            }
            else
            {
                @event.RsvpClosesAtUtc = null;
            }

            request.StartsAtLocal.TryConvertToUtc(request.TimeZoneId, out var startsAtUtc);
            @event.StartsAtUtc = startsAtUtc;

            request.EndsAtLocal.TryConvertToUtc(request.TimeZoneId, out var endsAtUtc);
            @event.EndsAtUtc = endsAtUtc;

            await EventRepositoryWrite.Update(@event).ConfigureAwait(false);

            return(Ok(Mapper.MapResponse(@event, DateTimeProvider)));
        }
示例#2
0
        public async Task <IActionResult> UnpublishEvent(Guid eventId)
        {
            var @event = await EventRepositoryRead.GetById(eventId).ConfigureAwait(false);

            if (@event == null)
            {
                return(NotFound("Event not found with id " + eventId));
            }

            @event.IsPublished = true;

            await EventRepositoryWrite.Update(@event).ConfigureAwait(false);

            return(Ok(Mapper.MapResponse(@event, DateTimeProvider)));
        }
示例#3
0
        public async Task <IActionResult> AddMember(Guid eventId, [FromBody] NewMemberRequest newMember)
        {
            if (newMember == null)
            {
                throw new ArgumentNullException(nameof(newMember));
            }

            var @event = await EventRepositoryRead.GetById(eventId).ConfigureAwait(false);

            if (@event == null)
            {
                return(NotFound("Event not found with id " + eventId));
            }

            var member = new Member
            {
                IsAttending  = newMember.IsAttending,
                IsOrganizer  = newMember.IsOrganizer,
                EmailAddress = newMember.EmailAddress,
                Name         = newMember.Name,
            };

            foreach (var response in newMember.FormResponses)
            {
                member.Responses.Add(response);
            }

            EventService.AddMember(@event, member);
            await EventRepositoryWrite.Update(@event).ConfigureAwait(false);

            try
            {
                // TODO: Get hardcoded strings into config
                Emailer?.Send(new Email
                {
                    From = new EmailAddress {
                        Address = "*****@*****.**", Name = "Fursvp.com"
                    },
                    To = new EmailAddress {
                        Address = newMember.EmailAddress, Name = newMember.Name
                    },
                    Subject          = $"{@event.Name}: Your event registration",
                    PlainTextContent = @$ "{newMember.Name}: We've got you on the list! View the event details or review and change your response at Fursvp.com.",
                    HtmlContent      = @$ "{HttpUtility.HtmlEncode(newMember.Name)}: We've got you on the list! View the event details or review and change your response at <a href=" "https://www.fursvp.com" ">FURsvp.com</a>.",
                });
            }