//------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public void AddUser(int boardId, String userName)
        {
            ActiveBoard board = this.GetBoard(boardId);

            /*cream un nou user*/
            ActiveUser user = new ActiveUser() {
                Changes = new List<Change>(),
                Right = ActiveUser.Rights.Write,
                Username = userName
            };

            /*cream si o noua entitate*/
            UserRight entity = new UserRight() {
                BoardId = boardId,
                Right = 1,
                User = userName
            };

            user.Entity = entity;

            /*adaugam in bd*/
            lock (this._em.UserRights) {
                this._em.UserRights.AddObject(user.Entity);
                this._em.SaveChanges();
            }
            /*adaugam si in active board*/
            board.UsersTable.Add(user.Username, user);
        }
        //------------------------------------------------------------------------------------------
        public void DuplicateBoard(int boardId)
        {
            // scoatem entitatea si ii copiem valorile
            var res = (from d in this._em.Boards
                       where d.Id == boardId
                       select d).ToList();

            if (res.Count() < 1)
                return;

            Board b = res[0];
            Board newBoard = new Board();
            newBoard.Name = b.Name + " Copy";
            newBoard.Owner = b.Owner;
            newBoard.Seed = b.Seed;
            this._em.AddToBoards(newBoard);
            /*salvam modificarile sa generam un id nou*/
            this._em.SaveChanges();

            //scoatem fiecare layer continut si generam entitati duplicate
            var res1 = (from d in this._em.Layers
                        where d.BoardId == boardId
                        select d).ToList();

            foreach (Layer l in res1)
            {
                Layer newLayer = new Layer();
                newLayer.BoardId = newBoard.Id;
                newLayer.LayerId = l.LayerId;
                newLayer.Name = l.Name;
                newLayer.Order = l.Order;

                this._em.AddToLayers(newLayer);
                this._em.SaveChanges();

                /* duplicam widgeturile pentru fiecare layer in bd*/
                var res2 = (from d in this._em.Widgets
                            where d.LayerId == l.LayerId
                            select d).ToList();

                foreach (Widget w in res2)
                {
                    Widget newWidget = new Widget();
                    newWidget.LayerId = newLayer.Id;
                    newWidget.WidgetId = w.WidgetId;
                    newWidget.Type = w.Type;
                    newWidget.Data = w.Data;
                    newWidget.Name = w.Name;
                    newWidget.Order = w.Order;

                    this._em.AddToWidgets(newWidget);
                }
            }

            /* duplicam drepturile userilor asupra boardului*/
            var res3 = (from d in this._em.UserRights
                        where d.BoardId == boardId
                        select d).ToList();

            foreach (UserRight ur in res3)
            {
                UserRight u = new UserRight();
                u.BoardId = ur.BoardId;
                u.Right = ur.Right;
                u.User = ur.User;
                this._em.AddToUserRights(u);
            }
            this._em.SaveChanges();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the UserRights EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserRights(UserRight userRight)
 {
     base.AddObject("UserRights", userRight);
 }
 /// <summary>
 /// Create a new UserRight object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="boardId">Initial value of the BoardId property.</param>
 /// <param name="user">Initial value of the User property.</param>
 /// <param name="right">Initial value of the Right property.</param>
 public static UserRight CreateUserRight(global::System.Int32 id, global::System.Int32 boardId, global::System.String user, global::System.Int32 right)
 {
     UserRight userRight = new UserRight();
     userRight.Id = id;
     userRight.BoardId = boardId;
     userRight.User = user;
     userRight.Right = right;
     return userRight;
 }
Example #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserRights EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserRights(UserRight userRight)
 {
     base.AddObject("UserRights", userRight);
 }