//------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public Board CreateBoard(IPrincipal user, String name)
        {
            if (!user.Identity.IsAuthenticated)
                return null;

            /*cream o tabla goala*/
            Board tmp = new Board();
            tmp.Name = name;
            tmp.Owner = user.Identity.Name;

            /*o adaugam in abza noastra de date*/
            this._em.AddToBoards(tmp);
            /*salvam schimbarile*/
            this._em.SaveChanges();

            return tmp;
        }
        //------------------------------------------------------------------------------------------
        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>
 /// Create a new Board object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="owner">Initial value of the Owner property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Board CreateBoard(global::System.Int32 id, global::System.String owner, global::System.String name)
 {
     Board board = new Board();
     board.Id = id;
     board.Owner = owner;
     board.Name = name;
     return board;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Boards EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBoards(Board board)
 {
     base.AddObject("Boards", board);
 }