Пример #1
0
 public ActionResult Create(GroupCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var      id    = User.Identity.GetUserId();
             ObjectId oId   = new ObjectId(id);
             Group    group = new Group {
                 Creator = oId, Description = model.Description, CreationTime = DateTime.Now, Name = model.Name, Members = new Dictionary <MongoDB.Bson.ObjectId, GroupPermissionType>()
                 {
                     { oId, GroupPermissionType.Owner }
                 }
             };
             _groupManager.AddGroup(group);
             return(RedirectToAction("Index", "Home"));
         }
         catch (Exception)
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     else
     {
         return(View());
     }
 }