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<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);
 }