Ejemplo n.º 1
0
        public Models.Meeting CreateOrUpdateMeeting(Models.Meeting meeting)
        {
            var foundMeeting = GetMeetingById(meeting.Id);
            var rowsAffected = 0;

            if (foundMeeting != null)
            {
                foundMeeting.Update(meeting);
            }
            else
            {
                _context.Meeting.Add(meeting);
            }

            try
            {
                rowsAffected += _context.SaveChanges();
            }
            catch (SqlException e)
            {
                _logger.Error("Error adding meeting {meeting}", meeting);

                if (e.InnerException is UpdateException)
                {
                    throw new MeetingUpdateException("Failed to insert meeting");
                }
                throw;
            }

            _logger.Information("Saved meeting changes for {meeting} {rowsAffected}", meeting, rowsAffected);
            return GetMeetingById(meeting.Id);
        }
Ejemplo n.º 2
0
 public IHttpActionResult Create([FromBody] Meeting meeting)
 {
     try
     {
         var meetingid      = _store.CreateMeeting(meeting.OrganizorId, meeting.VisitorEmail, meeting.Mobile, System.DateTime.Parse(meeting.DateTime), meeting.Purpose);
         var meetingCreated = GetMeeting(meetingid);
         try
         {
             var gmail = new GmailServer();
             gmail.Send(
                 meetingCreated.VisitorEmail,
                 _mailMessageBuilder.BuildSubject(meetingCreated.OrganizorName),
                 _mailMessageBuilder.BuildBody(meetingCreated)
                 );
         }
         catch (System.Exception)
         {
             return(Created("Meeting", meetingCreated));
         }
         return(Ok(meetingCreated));
     }
     catch (System.Exception ex)
     {
     }
     return(BadRequest());
 }
Ejemplo n.º 3
0
        public Models.Meeting InsertOrUpdateMeeting(Models.Meeting meeting)
        {
            var rowsAffected = 0;

            if (_context.Entry(meeting).State == EntityState.Detached)
            {
                // Update object graph using GraphDiff
                meeting = _context.UpdateGraph(meeting, map => map
                    .OwnedEntity(entity => entity.AnonymousMeetingPart,
                        with => with.AssociatedEntity(c => c.AnonymousMeeting))
                    .AssociatedCollection(g => g.Genres)
                    .AssociatedCollection(t => t.Tags)
                );
            }

            try
            {
                rowsAffected += _context.SaveChanges();
            }
            catch (SqlException e)
            {
                _logger.Error("Error adding {meeting}", meeting);

                if (e.InnerException is UpdateException)
                {
                    throw new MeetingUpdateException("Failed to insert meeting");
                }
                throw;
            }

            _logger.Information("Saved meeting changes for {meeting} {rowsAffected}", meeting, rowsAffected;
            return GetMeetingById(meeting.Id);
        }
Ejemplo n.º 4
0
 public static DTO.Meeting ToDto(this Models.Meeting src)
 {
     return(Mapper.Map <DTO.Meeting>(src));
 }
Ejemplo n.º 5
0
 public void Update(UpdateMeetingInput input)
 {
     Models.Meeting output = Mapper.Map <UpdateMeetingInput, Models.Meeting>(input);
     _meetingManager.Update(output);
 }
Ejemplo n.º 6
0
 public async Task Create(CreateMeetingInput input)
 {
     Models.Meeting output = Mapper.Map <CreateMeetingInput, Models.Meeting>(input);
     await _meetingManager.Create(output);
 }
Ejemplo n.º 7
0
        public static void Initialize(MeetingContext context)
        {
            context.Database.EnsureCreated();

            //check for seed
            if (context.Prayers.Any())
            {
                return;
            }

            var Meetings = new Models.Meeting[]
            {
                new Models.Meeting {
                    MeetingDate = DateTime.Parse("2016-09-01"), Conductor = "Br. Worthington"
                }
            };

            foreach (Models.Meeting m in Meetings)
            {
                context.Meetings.Add(m);
            }
            context.SaveChanges();

            var Hymns = new Hymn[]
            {
                new Hymn {
                    Number = 20, Title = "Come, Come Ye Saints", Order = HymnOrder.Open
                },
                new Hymn {
                    Number = 175, Title = "O God, The Eternal Father", Order = HymnOrder.Sacrament
                },
                new Hymn {
                    Number = 81, Title = "Press Forward, Saints", Order = HymnOrder.Optional
                },
                new Hymn {
                    Number = 2, Title = "The Spirit of God", Order = HymnOrder.Close
                }
            };

            foreach (Hymn h in Hymns)
            {
                context.Hymns.Add(h);
            }
            context.SaveChanges();

            var Speakers = new Speaker[]
            {
                new Speaker {
                    SpeakerName = "Gordon Smith", Subject = "Baptism", Order = 1
                },
                new Speaker {
                    SpeakerName = "Jennifer Smith", Subject = "The Gift of the Holy Ghost", Order = 2
                },
                new Speaker {
                    SpeakerName = "Doug Smith", Subject = "Endure to the End", Order = 3
                }
            };

            foreach (Speaker s in Speakers)
            {
                context.Speakers.Add(s);
            }
            context.SaveChanges();

            var Prayers = new Prayer[]
            {
                new Prayer {
                    PrayerName = "Celeste Smith", Order = PrayerOrder.Open
                },
                new Prayer {
                    PrayerName = "Vernon Smith", Order = PrayerOrder.Close
                }
            };

            foreach (Prayer p in Prayers)
            {
                context.Prayers.Add(p);
            }
            context.SaveChanges();
        }
Ejemplo n.º 8
0
 public void Create([FromBody] Meeting meeting)
 {
     _store.CreateMeeting(meeting.OrganizorId, meeting.VisitorEmail, meeting.Mobile, System.DateTime.Parse(meeting.DateTime), meeting.Purpose);
 }