Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "ID,Sync,LastUpdate")] Room room, string[] ModsAllowedID)
 {
     if (ModelState.IsValid)
     {
         Room roomBefore = db.Rooms.Find(room.ID);
         // handle mods
         roomBefore.ModeratorsAllowed.Clear();
         if (ModsAllowedID == null)
         {
             ModsAllowedID = new string[0];
         }
         List <Moderator> newModeratorsAllowed = db.Moderators.Where(m => ModsAllowedID.Contains(m.Username)).ToList();
         roomBefore.ModeratorsAllowed.Add(roomBefore.Moderator);
         foreach (Moderator m in newModeratorsAllowed)
         {
             roomBefore.ModeratorsAllowed.Add(m);
         }
         // handle sync
         if (room.Sync && !roomBefore.Sync)
         {
             //VmtDevAPIRegisterLiveChat(room.ID);
             VmtDevAPI.RegisterLiveActions(room.ID);
         }
         if (!room.Sync && roomBefore.Sync)
         {
             VmtDevAPI.CloseSocket(room.ID);
         }
         roomBefore.Sync            = room.Sync;
         db.Entry(roomBefore).State = EntityState.Modified;    // TODO check disable?
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ID = new SelectList(db.Groups, "RoomID", "UsernamesAsString", room.ID);
     return(View(room));
 }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Username")] Moderator moderator)
 {
     if (ModelState.IsValid)
     {
         db.Entry(moderator).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(moderator));
 }