예제 #1
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();
     }
 }
예제 #2
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");
 }
 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");
 }