Exemple #1
0
        //=== Manage: Order Data

        /// <summary> Get OrderData. </summary>
        /// <param name="door">Get the Door? Default false.</param>
        /// <param name="window">Get the Window? Default false.</param>
        /// <param name="frame">Get the Frame? Default false.</param>
        public OrderData GetOrderData(int id, bool door = false, bool window = false, bool frame = false)
        {
            if (id < 1)
            {
                throw new CoreException("No Id Specified!");
            }

            OrderData orderData = repository.GetEntity <OrderData>(id);

            if (orderData == null)
            {
                return(null);
            }

            if (door && orderData.IdDoor.HasValue)
            {
                orderData.Door = dMan.GetDoor(orderData.IdDoor.Value);
            }

            if (window && orderData.IdWindow.HasValue)
            {
                orderData.Window = wMan.GetWindow(orderData.IdWindow.Value);
            }

            if (frame && orderData.IdFrame.HasValue)
            {
                orderData.Frame = fMan.GetFrame(orderData.IdFrame.Value);
            }

            return(orderData);
        }
        public ActionResult DoorDetails(int id)
        {
            Door door = dMan.GetDoor(id, kind: true, connection: true, glass: true);

            // Merge childs into door
            dMan.MergeAllIntoDoors(new List <Door>()
            {
                door
            });


            ViewData["door"] = door;
            return(View(views + "_DoorDetails.cshtml"));
        }
        //=== Manage: Frame

        /// <summary> Get Frame. </summary>
        /// <param name="sill">Get Sill? Default false.</param>
        /// <param name="connection">Get Connection? Default false.</param>
        /// <param name="glass">Get Glass? Default false.</param>
        /// <param name="window">Get Window? Default false.</param>
        /// <param name="door">Get Door? Default false.</param>
        /// <returns></returns>
        public Frame GetFrame(int id, bool sill = false, bool connection = false, bool glass = false, bool window = false, bool door = false)
        {
            // Check
            if (id < 1)
            {
                return(null);
            }

            Frame frame = repository.GetEntity <Frame>(id);

            if (frame == null)
            {
                return(null);
            }

            // Get children
            if (connection)
            {
                frame.Connection = cMan.GetConnection(frame.IdConnection);
            }

            if (sill && frame.IdFrameSill.HasValue)
            {
                frame.FrameSill = GetFrameSill(frame.IdFrameSill.Value);
            }

            if (glass && frame.IdGlass.HasValue)
            {
                frame.Glass = gMan.GetGlass(frame.IdGlass.Value);
            }

            if (window && frame.IdWindow.HasValue)
            {
                frame.Window = wMan.GetWindow(frame.IdWindow.Value);
            }

            if (door && frame.IdDoor.HasValue)
            {
                frame.Door = dMan.GetDoor(frame.IdDoor.Value);
            }

            return(frame);
        }
Exemple #4
0
        /// <summary> Merge door into orderdata. </summary>
        public void MergeDoorsIntoOrderData(List <OrderData> orderDatas)
        {
            if (orderDatas.IsNullOrEmpty())
            {
                return;
            }

            DoorManager dMan = new DoorManager();

            // Single DB query
            //// Get Doors for orders
            //int[] doorIds = orderDatas.Select(x => x.IdDoor).Where(x => x.HasValue).Select(x => x.Value).ToArray();
            //List<Door> doors = dMan.GetDoor(doorIds);

            //// Merge data into doors
            //dMan.MergeAllIntoDoors(doors);

            //// Merge doors into orderdata
            //foreach (OrderData data in orderDatas)
            //{
            //    if (!doors.Any(x => x.Id == data.IdDoor))
            //        continue;

            //    data.Door = doors.FirstOrDefault(x => x.Id == data.IdDoor);
            //}

            // Multiple DB queries
            foreach (OrderData data in orderDatas)
            {
                if (!data.IdDoor.HasValue || data.IdDoor.Value <= 0)
                {
                    continue;
                }

                data.Door = dMan.GetDoor(data.IdDoor.Value, kind: true, connection: true, glass: true);
            }
        }