示例#1
0
 public void Delete(Room entity)
 {
     if (AuthorizedUsers["Delete"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         RoomController.Delete(entity);
     }
 }
示例#2
0
        public async Task <ActionResult> Delete(int id)
        {
            try
            {
                string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                await _roomController.Delete(id, userId);

                // TODO: Move to separate chat hub manager
                await _chatHub.Clients.All.SendAsync("RefreshRooms");

                RoomResponse res = new RoomResponse()
                {
                    Type    = "success",
                    Message = "Room deleted."
                };
                return(new JsonResult(res));
            }
            catch
            {
                RoomResponse res = new RoomResponse()
                {
                    Type    = "error",
                    Message = "Error: Something went wrong with deleting the room."
                };
                return(new JsonResult(res));
            }
        }