Exemplo n.º 1
0
        public async Task<ActionResult> Details(int id) {
            var model = new ConferenceDetailsViewModel();
            //1. First fetch the conference details form the database.
            using (var db = new ConferenceContext())
            {
                var conference = db.Conferences.FirstOrDefault(c => c.Id == id);
                if (conference != null)
                    model.Conference = conference;
            }

            try
            {
                var conf = await Getconference(model.Conference.ConferenceId.ToString()).Get();
                // store the participants in the result model
                model.Participants = conf.Participants;
            }
            catch (Exception)
            {
                model.Participants = new IParticipant[0];
                //do nothing, just means no one is in the conference
            }


            return View(model);
        }
Exemplo n.º 2
0
 public ActionResult Index() {
     using (var db = new ConferenceContext())
     {
         var model = db.Conferences.ToList();
         return View(model);
     }
 }
 public ActionResult MyConferences() {
     using (var db = new ConferenceContext())
     {
         var conferences = db.Conferences.Where(m => m.OwnerId == User.Identity.Name).ToList();
         return View(conferences);
     }
 }
Exemplo n.º 4
0
 public async void AddParticipant(string name) {
     using (var db = new ConferenceContext())
     {
         db.CurrentParticipants.Add(new CurrentParticipant
         {
             Name = name,
             Joined = DateTime.UtcNow
         });
         await db.SaveChangesAsync();
     }
 }
Exemplo n.º 5
0
 public async Task<RedirectToRouteResult> Create(Conference model) {
     using (var db = new ConferenceContext())
     {
         // lets add a new guid to the model to ensure that all conferences are uniq
         model.ConferenceId = Guid.NewGuid();
         //save it
         db.Conferences.Add(model);
         await db.SaveChangesAsync();
     }
     //return tohome controller
     return RedirectToAction("Index");
 }
 public async Task<ActionResult> Create(CreateConferenceModel model) {
     using (var db = new ConferenceContext())
     {
         // lets add a new guid to the model to ensure that all conferences are uniq
         model.Conference.ConferenceId = Guid.NewGuid();
         var utcdate = model.Conference.ConferenceEndDate.ToUniversalTime();
         model.Conference.ConferenceEndDate = utcdate.Date;
         model.Conference.OwnerId = User.Identity.Name;
         db.Conferences.Add(model.Conference);
         await db.SaveChangesAsync();
     }
     return RedirectToAction("MyConferences");
 }
 private async Task ConnectToConference(string pinCode, string cli, IIceSvamletBuilder builder) {
     using (var db = new ConferenceContext()) {
         var conference =
             await
                 db.Conferences.FirstOrDefaultAsync(
                     c => c.PinCode == pinCode && (c.ConferenceEndDate >= DateTime.Today || c.ValidForever));
         if (conference != null) {
             builder.ConnectConference(conference.ConferenceId.ToString()).WithCli(cli);
             // builder.SaySsml("<speak version =\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xml:lang=\"en-US\"><break strength=\"medium\" /><prosody rate=\"slow\">Welcome to the <break strength=\"medium\" />conference </prosody></speak>");
             builder.Say("ah, Welcome to the conference");
         } else {
             builder.Say("Invalid code").Hangup(HangupCause.Normal);
         }
     }
 }
 public async Task<ActionResult> Create() {
     var model = new CreateConferenceModel();
     model.Conference = new Conference();
     model.Conference.ConferenceEndDate = DateTime.Today.AddDays(5);
     model.Conference.OwnerId = User.Identity.Name;
     var code = "";
     using (var db = new ConferenceContext())
     {
         var rng = new Random();
         var value = rng.Next(100, 9999); //1
         code = value.ToString("0000");
         while (
             db.Conferences.Any(
                 m => m.PinCode == code && (m.ConferenceEndDate <= DateTime.Today || m.ValidForever)))
         {
             value = rng.Next(100, 9999); //1
             code = value.ToString("0000");
         }
     }
     model.Conference.PinCode = code;
     return View(model);
 }
        public async Task<ViewResult> Details(Guid id) {
            var model = new ConferenceDetailsViewModel();
            using (var db = new ConferenceContext())
            {
                var conference =
                    db.Conferences.FirstOrDefault(m => m.OwnerId == User.Identity.Name && m.ConferenceId == id);
                model.Conference = conference;
                try
                {
                    var conf = await Getconference(conference.ConferenceId.ToString()).Get();
                    // store the participants in the result model

                    if (conf != null)
                    {
                        model.Participants = conf.Participants;
                    }
                    else
                    {
                        model.Participants = new IParticipant[0];
                    }
                }
                catch (Exception)
                {}

                return View(model);
            }
        }
 public async Task<RedirectToRouteResult> Delete(Guid id) {
     using (var db = new ConferenceContext())
     {
         var conference =
             db.Conferences.FirstOrDefault(m => m.OwnerId == User.Identity.Name && m.ConferenceId == id);
         db.Conferences.Remove(conference);
         await db.SaveChangesAsync();
     }
     return RedirectToAction("MyConferences");
 }