public IHttpActionResult MenuBlock() { try { MenuRepository menuRepo = new MenuRepository(); BlockRepository blockRepo = new BlockRepository(); SectionCollectionViewModel model = new SectionCollectionViewModel(); foreach (KeyValuePair<int, string> section in Constants.SECTION) { model.menu.Add(section.Value, menuRepo.GetByPosition(section.Key)); } foreach (KeyValuePair<int, string> section in Constants.BLOCK_SECTION) { model.block.Add(section.Value, blockRepo.GetByPosition(section.Key)); } return Ok(model); } catch (Exception ex) { return BadRequest(ex.Message); } }