mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add search computer by letter.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user