|
FOYDALANILGAN ADABIYOTLAR
|
bet | 4/5 | Sana | 26.01.2024 | Hajmi | 0,58 Mb. | | #146369 |
Bog'liq Kurs ishi (0)
1.https://metanit.com
2.https://docs.dot-net.uz/c-.net/web-development/asp.net-core-mvc/asp.net-core-mvc
3.https://w3layouts.com
Ilovalar
Controller kodidan namunalar:
HomeController:
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using shop.Context;
using shop.Models;
using System.Diagnostics;
namespace shop.Controllers
{
public class HomeController : Controller
{
private readonly ILogger _logger;
private readonly ApplicationDbContext db;
public HomeController(ILogger logger, ApplicationDbContext db)
{
_logger = logger;
this.db = db;
}
[HttpPost]
public IActionResult Login(string telnumber, string password)
{
if(telnumber == "990012233" && password == "12345")
{
return RedirectToAction("Index", "Dashboard");
} else
{
return View();
}
}
[HttpPost]
public IActionResult Search(string search)
{
var categories = db.categories.ToList();
var subcategories = db.subcategories.ToList();
var products = db.products.Where(el => el.desc.Contains(search) || el.name.Contains(search)).ToList();
if(search == null)
{
products = db.products.ToList();
}
return View("Index",new Tuple, List
, List>(categories, products, subcategories));
}
public IActionResult Index()
{
var categories = db.categories.ToList();
var subcategories = db.subcategories.ToList();
var products = db.products.ToList();
return View(new Tuple, List
, List>(categories, products, subcategories));
}
public IActionResult Login()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
|
| |