Add search computer by letter.

This commit is contained in:
2018-04-14 05:40:28 +01:00
parent d043ef3333
commit 113cebe789
4 changed files with 118 additions and 4 deletions

View File

@@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Cicm.Database.Schemas;
using cicm_web.Models;
using Microsoft.AspNetCore.Mvc;
using Computer = Cicm.Database.Schemas.Computer;
namespace cicm_web.Controllers
{
@@ -18,5 +19,20 @@ namespace cicm_web.Controllers
return View();
}
public IActionResult ByLetter(char id)
{
// ToUpper()
if(id >= 'a' && id <= 'z') id -= (char)32;
// Check if not letter
if(id < 'A' || id > 'Z') id = '\0';
ViewBag.Letter = id;
ComputerMini[] computers =
id == '\0' ? ComputerMini.GetAllItems() : ComputerMini.GetItemsStartingWithLetter(id);
return View(computers);
}
}
}