예제 #1
0
        public void UpdateEvent(EventToolDto eventReservation, int eventId, string token)
        {
            var eventDto = PopulateReservationDto(eventReservation);

            eventDto.EventId = eventId;
            _eventService.UpdateEvent(eventDto);
        }
예제 #2
0
        private MpEventReservationDto PopulateReservationDto(EventToolDto eventTool)
        {
            var eventDto = new MpEventReservationDto();

            eventDto.CongregationId       = eventTool.CongregationId;
            eventDto.ContactId            = eventTool.ContactId;
            eventDto.Description          = eventTool.Description;
            eventDto.DonationBatchTool    = eventTool.DonationBatchTool;
            eventDto.EndDateTime          = eventTool.EndDateTime;
            eventDto.EventTypeId          = eventTool.EventTypeId;
            eventDto.MeetingInstructions  = eventTool.MeetingInstructions;
            eventDto.MinutesSetup         = eventTool.MinutesSetup;
            eventDto.MinutesTeardown      = eventTool.MinutesTeardown;
            eventDto.ProgramId            = eventTool.ProgramId;
            eventDto.ParticipantsExpected = eventTool.ParticipantsExpected;
            if (eventTool.ReminderDaysId > 0)
            {
                eventDto.ReminderDaysId = eventTool.ReminderDaysId;
            }
            eventDto.Cancelled     = eventTool.Cancelled;
            eventDto.SendReminder  = eventTool.SendReminder;
            eventDto.StartDateTime = eventTool.StartDateTime;
            eventDto.Title         = eventTool.Title;
            return(eventDto);
        }
예제 #3
0
        public int AddEvent(EventToolDto eventReservation)
        {
            var eventDto = PopulateReservationDto(eventReservation);
            var eventId  = _eventService.CreateEvent(eventDto);

            return(eventId);
        }
예제 #4
0
        public bool CreateEventReservation(EventToolDto eventTool, string token)
        {
            try
            {
                var eventId = AddEvent(eventTool);

                foreach (var room in eventTool.Rooms)
                {
                    AddRoom(eventId, room, token);
                    foreach (var equipment in room.Equipment)
                    {
                        AddEquipment(equipment, eventId, room, token);
                    }
                }

                if (eventTool.Group != null)
                {
                    var groupid = AddGroup(eventTool.Group);
                    AddEventGroup(eventId, groupid, token);
                }
            }
            catch (Exception ex)
            {
                var msg = "Event Service: CreateEventReservation";
                _logger.Error(msg, ex);
                throw new Exception(msg, ex);
            }
            return(true);
        }
예제 #5
0
        private void UpdateEventChildcareGroup(EventToolDto oldEventDetails, EventToolDto eventReservation, int eventId, string token)
        {
            bool wasChildcare = oldEventDetails.EventTypeId == childcareEventTypeID;
            bool isChildcare  = eventReservation.EventTypeId == childcareEventTypeID;

            //if it use to be a childcare event, but isn't anymore, remove the group
            if (wasChildcare && !isChildcare)
            {
                _eventService.DeleteEventGroupsForEvent(eventId, token, childcareGroupTypeID);
                _groupService.EndDateGroup(oldEventDetails.Group.GroupId, null, null);
            }
            //now is a childcare event but was not before so add a group
            else if (!wasChildcare && isChildcare)
            {
                eventReservation.Group.CongregationId = eventReservation.CongregationId;
                var groupid = AddGroup(eventReservation.Group);
                AddEventGroup(eventId, groupid, token);
            }
            //it was and still is a childcare event
            else if (wasChildcare && isChildcare)
            {
                var group = _eventService.GetEventGroupsForEventAPILogin(eventId).FirstOrDefault(i => i.GroupTypeId == childcareGroupTypeID);

                eventReservation.Group.GroupId        = group.GroupId;
                eventReservation.Group.CongregationId = eventReservation.CongregationId;
                UpdateGroup(eventReservation.Group);
            }
        }
예제 #6
0
        public IHttpActionResult Post([FromBody] EventToolDto eventReservation)
        {
            if (ModelState.IsValid)
            {
                return(Authorized(token =>
                {
                    try
                    {
                        _eventService.CreateEventReservation(eventReservation, token);
                        return Ok();
                    }
                    catch (Exception e)
                    {
                        var msg = "EventToolController: POST " + eventReservation.Title;
                        logger.Error(msg, e);
                        var apiError = new ApiErrorDto(msg, e);
                        throw new HttpResponseException(apiError.HttpResponseMessage);
                    }
                }));
            }
            var errors    = ModelState.Values.SelectMany(val => val.Errors).Aggregate("", (current, err) => current + err.Exception.Message);
            var dataError = new ApiErrorDto("Event Data Invalid", new InvalidOperationException("Invalid Event Data" + errors));

            throw new HttpResponseException(dataError.HttpResponseMessage);
        }
예제 #7
0
        public bool UpdateEventReservation(EventToolDto eventReservation, int eventId, string token)
        {
            try
            {
                var oldEventDetails = GetEventDetails(eventId, true, false);

                foreach (var room in oldEventDetails.Rooms)
                {
                    if (!room.Cancelled)
                    {
                        if (!eventReservation.Rooms.Any(r => r.RoomId == room.RoomId) || oldEventDetails.StartDateTime != eventReservation.StartDateTime)
                        {
                            room.Cancelled = true;
                            foreach (var eq in room.Equipment)
                            {
                                eq.Cancelled = true;
                                eq.Notes     = "***Cancelled***" + eq.Notes;
                            }
                            UpdateEventRoom(room, eventId, token);
                        }
                    }
                }

                UpdateEventChildcareGroup(oldEventDetails, eventReservation, eventId, token);
                UpdateEvent(eventReservation, eventId, token);

                foreach (var room in eventReservation.Rooms)
                {
                    UpdateEventRoom(room, eventId, token);
                }
            }
            catch (Exception ex)
            {
                var msg = "Event Service: UpdateEventReservation";
                _logger.Error(msg, ex);
                throw new Exception(msg, ex);
            }
            return(true);
        }