public IHttpActionResult GetShapeById(int Id) { var shape = shapeService.GetShape(Id); if (shape != null) { return(Ok(shape)); } return(NotFound()); }
public void Start(string input) { _logger.LogInformation($"Starting game using '{input}'"); var items = input.Split(','); foreach (var item in items) { char code = item[0]; var col = Convert.ToUInt16(item.Substring(1, item.Length - 1)); var shape = _shapeService.GetShape(code); _boardService.Drop(shape, col); } }
public DataTableResponse GetSamples(DataTableRequest request, int sort) { // Query samples var samples = sampleService.GetSamples(); // Searching Data IEnumerable <Sample> filteredSamples; if (request.Search.Value != "") { var searchText = request.Search.Value.Trim(); filteredSamples = samples.Where(p => p.Name.Contains(searchText)); } else { filteredSamples = samples; } // Sort Data if (request.Order.Any()) { int sortColumnIndex = request.Order[0].Column; string sortDirection = request.Order[0].Dir; Func <Sample, string> orderingFunctionString = null; Func <Sample, int> orderingFunctionInt = null; switch (sortColumnIndex) { case 0: // SampleID { orderingFunctionInt = (c => c.Id); filteredSamples = sortDirection == "asc" ? filteredSamples.OrderByDescending(orderingFunctionInt) : filteredSamples.OrderByDescending(orderingFunctionInt); break; } case 1: // SampleName { orderingFunctionString = (c => c.Name); filteredSamples = sortDirection == "asc" ? filteredSamples.OrderBy(orderingFunctionString) : filteredSamples.OrderByDescending(orderingFunctionString); break; } case 6: // UnitPrice { break; } } } // Paging Data var pagedSamples = filteredSamples.Skip(request.Start).Take(request.Length); var returnData = pagedSamples.ToArray(); foreach (var item in returnData) { item.Shape = shapeService.GetShape(item.ShapeId); } List <int> listSort = new List <int>(); if (sort != 0) { listSort = productService.GetSampleIdByProductId(sort); returnData = returnData.OrderByDescending(d => listSort.IndexOf(d.Id)).ToArray(); } return(new DataTableResponse { draw = request.Draw, recordsTotal = samples.Count(), recordsFiltered = samples.Count(), data = returnData, error = "" }); }