I am trying to make searcher. It should search through prices in table Repairs. I don't know how to resolve this problem. My only idea was to parse string to float using float.Parse method but it doesn't work.
Model
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace CallCenterService.Controllers
{
public class AccountantController : Controller
{
private readonly DatabaseContext _context;
public AccountantController(DatabaseContext context)
{
_context = context;
}
// GET: /<controller>/
public async Task<IActionResult> Index(string searchServicePrice, string searchPartsPrice, string searchSummaryPrice)
{
var name = from m in _context.Repairs
select m;
if (!String.IsNullOrEmpty(searchServicePrice))
{
float.Parse(searchServicePrice, CultureInfo.InvariantCulture.NumberFormat);
name = name.Where(s => s.Price.Equals(searchServicePrice));
}
View
@model IEnumerable<CallCenterService.Models.Repair>
@{
ViewData["Title"] = "Index";
}
<h2>Index</h2>
<form asp-controller="Accountant" asp-action="Index" method="get">
<p>
Service Price : <input type="text" name="searchServicePrice">
Parts Price : <input type="text" name="searchPartsPrice">
Summary Price: <input type="text" name="searchSummaryPrice">
<input type="submit" value="Filter" />
</p>
</form>