Exemplo n.º 1
0
        private void DataClient_OnResponseReceived(object sender, SpeechResponseEventArgs e)
        {
            try
            {
                var firstResult = e.PhraseResponse.Results.First();
                // _parts.Add(firstResult.LexicalForm);

                var content = new Content();
                content.MeetingId  = currentMeetingId;
                content.EmployeeId = Guid.Parse("BF49B343-97C2-4544-AC07-8964C269280D");
                content.Sequence   = 159;
                content.Line       = firstResult.LexicalForm;
                content.CategoryId = Guid.Parse("61027F10-21A9-4C91-B4C1-7E7E99A29853");

                using (var db = new AzureDb("Server=lofndb.database.windows.net;Database=lofn2;User Id=lofn;Password=Passw0rd; "))
                {
                    db.Contents.Add(content);

                    db.SaveChanges();
                    // TODO: Handle transaction and failures.
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        // POST api/values
        public Guid Post([FromBody] CreateMeetingViewModel data) // I know....we should use viewmodels... =O)
        {
            return(Guid.Empty);

            // TODO: Validate for the love of G*d...
            try
            {
                var meeting = new Meeting();
                meeting.Name     = data.Name;
                meeting.Location = data.Location;

                meeting.StartDate = DateTime.UtcNow;

                var loc = LocationsController.GetLocation(meeting.Location);
                meeting.Latitude  = loc.Key;
                meeting.Longitude = loc.Value;

                using (var db = new AzureDb("Server=lofndb.database.windows.net;Database=lofn2;User Id=lofn;Password=Passw0rd; "))
                {
                    db.Meetings.Add(meeting);

                    bool isOrganizer = true;
                    foreach (var p in data.ParticipantList)
                    {
                        var participant = new Participant {
                            EmployeeId = p, MeetingId = meeting.Id, Organizer = isOrganizer
                        };
                        db.Participants.Add(participant);
                        isOrganizer = false;
                    }

                    db.SaveChanges();
                    // TODO: Handle transaction and failures.
                }

                return(meeting.Id);
            }
            catch (Exception ex)
            {
                throw;
            }
        }