Beispiel #1
0
        public async Task <IHttpActionResult> AllPCs(BootGridRequest bootRequest)
        {
            //get all pcs with it's properties
            var pcs = _pcService.AllIncluding(item => item.CPU, item => item.Motherboard, item => item.PCMemories, item => item.PowerSupply, item => item.PCMemories.Select(e => e.Memory)).ToList()
                      .Select(item => new PCBootGridModel
            {
                Id             = item.Id,
                CustomerName   = item.CustomerName,
                Motherboard    = item.Motherboard.Name,
                MemoryAmount   = item.PCMemories.Sum(pcm => pcm.Memory.Size * pcm.Count),//get sum of memory size
                PowerSupply    = item.PowerSupply.Name,
                AssemblyNeeded = item.AssemblyNeeded,
                TotalPrice     = item.TotalPrice
            })
                      .Skip((bootRequest.current - 1) * bootRequest.rowCount) //skip the previous page
                      .Take(bootRequest.rowCount);                            //take number of items
            //setup bootgrid model
            var model = new BootGridResponse <PCBootGridModel>()
            {
                Current  = bootRequest.current,
                RowCount = bootRequest.rowCount,
                Rows     = pcs,
                Total    = _pcService.All.Count()
            };

            return(Ok(model));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> AllPCs(BootGridRequest bootRequest)
        {
            //get all pcs with it's properties
            var pcs = _pcService.AllIncluding(item => item.CPU, item => item.Motherboard, item => item.PCMemories,
                                              item => item.PowerSupply, item => item.PCMemories.Select(e => e.Memory))
                      .Select(item => new PCBootGridModel
            {
                Id             = item.Id,
                CustomerName   = item.CustomerName,
                Motherboard    = item.Motherboard.Name,
                MemoryAmount   = item.PCMemories.Sum(pcm => pcm.Memory.Size * pcm.Count), //get sum of memory size
                PowerSupply    = item.PowerSupply.Name,
                AssemblyNeeded = item.AssemblyNeeded,
                TotalPrice     = item.TotalPrice
            });

            //setup bootgrid model
            var model = new BootGridResponse <PCBootGridModel>(bootRequest, pcs);

            return(Ok(model));
        }