using Application.Domain.Entities; using Application.Models; using Infrastructure.Application; using Infrastructure.Data; using Infrastructure.Extensions; using Infrastructure.Web.Mvc; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Linq; namespace IoT.Shared.Areas.Admin.Controlls { [Authorize] [Area(nameof(Admin))] public class ParameterController : CrudController, EditParameterModel, EditParameterModel> { public ParameterController(IRepository repo) : base(repo) { } public override IQueryable Include(IQueryable query) { return query.Include(o => o.Api).ThenInclude(o => o.Product); } public override void ToDisplayModel(Parameter entity, EditParameterModel model) { if (entity != null) { model.ProductId = entity.Api.ProductId; ViewData.Add(model.ApiId, entity.Api.Name); ViewData.Add(model.ProductId, entity.Api.Product.Name); } } public override void ToEditModel(Parameter entity, EditParameterModel model) { this.ToDisplayModel(entity, model); } } }