Ejemplo n.º 1
0
        public static void Update(DrawerDTO updateDrawer)
        {
            try
            {
                databaseDataContext db = new databaseDataContext();

                var find =
                    (from drawer in db.Drawers
                     where drawer.Id == updateDrawer.Id
                     select drawer).Single();

                find.BoxId          = updateDrawer.BoxId;
                find.Width          = updateDrawer.Width;
                find.Height         = updateDrawer.Height;
                find.Depth          = updateDrawer.Depth;
                find.BoardThickness = updateDrawer.BoardThickness;
                find.PositionX      = updateDrawer.PositionX;
                find.PositionY      = updateDrawer.PositionY;
                find.PositionZ      = updateDrawer.PositionZ;
                find.Name           = updateDrawer.Name;
                find.Texture        = updateDrawer.Texture;
                find.pregrada       = updateDrawer.pregrada;

                db.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
        public static int Create(DrawerDTO drawerCreate)
        {
            try
            {
                databaseDataContext db = new databaseDataContext();

                Drawer drawer = new Drawer()
                {
                    BoxId          = drawerCreate.BoxId,
                    Width          = drawerCreate.Width,
                    Height         = drawerCreate.Height,
                    Depth          = drawerCreate.Depth,
                    BoardThickness = drawerCreate.BoardThickness,
                    PositionX      = drawerCreate.PositionX,
                    PositionY      = drawerCreate.PositionY,
                    PositionZ      = drawerCreate.PositionZ,
                    Name           = drawerCreate.Name,
                    Texture        = drawerCreate.Texture,
                    pregrada       = drawerCreate.pregrada
                };

                db.Drawers.InsertOnSubmit(drawer);
                db.SubmitChanges();

                return(drawer.Id);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(-1);
        }
Ejemplo n.º 3
0
        public static List <DrawerDTO> DrawersInBox(int boxId)
        {
            List <DrawerDTO> drawers = new List <DrawerDTO>();

            try
            {
                databaseDataContext db = new databaseDataContext();

                var find =
                    (from drawer in db.Drawers
                     where drawer.BoxId == boxId
                     select drawer);

                foreach (var d in find)
                {
                    DrawerDTO drawerRead = new DrawerDTO()
                    {
                        Id             = d.Id,
                        BoxId          = d.BoxId,
                        Width          = d.Width,
                        Height         = d.Height,
                        Depth          = d.Depth,
                        BoardThickness = d.BoardThickness,
                        PositionX      = d.PositionX,
                        PositionY      = d.PositionY,
                        PositionZ      = d.PositionZ,
                        Name           = d.Name,
                        Texture        = d.Texture,
                        pregrada       = d.pregrada
                    };

                    drawers.Add(drawerRead);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(drawers);
        }
Ejemplo n.º 4
0
        public static DrawerDTO Read(int drawerId)
        {
            DrawerDTO drawerRead = null;

            try
            {
                databaseDataContext db = new databaseDataContext();

                var find =
                    (from drawer in db.Drawers
                     where drawer.Id == drawerId
                     select drawer).Single();

                drawerRead = new DrawerDTO()
                {
                    Id             = find.Id,
                    BoxId          = find.BoxId,
                    Width          = find.Width,
                    Height         = find.Height,
                    Depth          = find.Depth,
                    BoardThickness = find.BoardThickness,
                    PositionX      = find.PositionX,
                    PositionY      = find.PositionY,
                    PositionZ      = find.PositionZ,
                    Name           = find.Name,
                    Texture        = find.Texture,
                    pregrada       = find.pregrada
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(drawerRead);
        }
Ejemplo n.º 5
0
        public void SaveConfiguration(string ArrayOfObjects, int planId)
        {
            //List<ObjectDTO> objects = (List<ObjectDTO>)JsonSerializer.DeserializeFromString(ArrayOfObjects, typeof(List<ObjectDTO>));
            ObjectDTO o = (ObjectDTO)JsonSerializer.DeserializeFromString(ArrayOfObjects, typeof(ObjectDTO));
            //foreach (ObjectDTO o in objects)
            //{


            //}

            BoxDTO box = new BoxDTO()
            {
                PlanId         = planId,
                Width          = o.Width,
                Height         = o.Height,
                Depth          = o.Depth,
                BoardThickness = o.BoardThickness,
                PositionX      = o.PositionX,
                PositionY      = o.PositionY,
                PositionZ      = o.PositionZ,
                Name           = o.Name,
                Texture        = o.Texture,
                vertikalno     = o.vertikalno,
                horizontalno   = o.horizontalno,
                globalX        = o.globalX,
                globalY        = o.globalY,
                globalZ        = o.globalZ
            };

            int boxId = Boxs.Create(box);

            foreach (BoardDTO b in o.childs)
            {
                BoardDTO board = new BoardDTO()
                {
                    BoxId          = boxId,
                    Width          = b.Width,
                    Height         = b.Height,
                    Depth          = b.Depth,
                    BoardThickness = b.BoardThickness,
                    PositionX      = b.PositionX,
                    PositionY      = b.PositionY,
                    PositionZ      = b.PositionZ,
                    Name           = b.Name,
                    Texture        = b.Texture
                };

                int boardId = Boards.Create(board);
            }

            List <int> pozicije = new List <int>();

            if (o.pozicije_fioka != null)
            {
                for (int i = 0; i < o.childs.Count + 1; i++)
                {
                    if (o.pozicije_fioka[i] == true)
                    {
                        pozicije.Add(i);
                    }
                }
            }

            int k = 0;

            foreach (DrawerDTO d in o.nizFioka)
            {
                DrawerDTO drawer = new DrawerDTO()
                {
                    BoxId          = boxId,
                    Width          = d.Width,
                    Height         = d.Height,
                    Depth          = d.Depth,
                    BoardThickness = d.BoardThickness,
                    PositionX      = d.PositionX,
                    PositionY      = d.PositionY,
                    PositionZ      = d.PositionZ,
                    Name           = d.Name,
                    Texture        = d.Texture,
                    pregrada       = pozicije[k]
                };

                int drawerId = Drawers.Create(drawer);
                k++;
            }

            pozicije = new List <int>();
            if (o.pozicije_vrata != null)
            {
                for (int i = 0; i < o.childs.Count + 1; i++)
                {
                    if (o.pozicije_vrata[i] == true)
                    {
                        pozicije.Add(i);
                    }
                }
            }

            k = 0;

            foreach (DoorDTO d in o.nizVrata)
            {
                DoorDTO door = new DoorDTO()
                {
                    BoxId     = boxId,
                    Width     = d.Width,
                    Height    = d.Height,
                    Depth     = d.Depth,
                    PositionX = d.PositionX,
                    PositionY = d.PositionY,
                    PositionZ = d.PositionZ,
                    Name      = d.Name,
                    Texture   = d.Texture,
                    pregrada  = pozicije[k]
                };

                int doorId = Doors.Create(door);
                k++;
            }
        }