You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/IoTCenter/Areas/Admin/Controllers/IoT/ProductController.cs

41 lines
1.2 KiB

using System.Linq;
using Application.Domain.Entities;
using Application.Models;
using Infrastructure.Application;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using IoTCenter.Services;
using IoTShared.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
namespace IoTCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class ProductController : CrudController<Product, PagedListModel<EditProductModel>, EditProductModel, EditProductModel>
{
public ProductController(IRepository<Product> repo) : base(repo)
{
}
public override IQueryable<Product> Include(IQueryable<Product> query)
{
return query.Include(o => o.Category);
}
public override void ToModel(Product entity, EditProductModel model)
{
model.CategoryName = entity.Category.Name;
model.CategoryNumber = entity.Category.Number;
}
public override void ToDisplayModel(Product entity, EditProductModel model)
{
this.ToModel(entity, model);
}
}
}