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/IoT.Shared/Areas/Admin/Controlls/ParameterController.cs

42 lines
1.3 KiB

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<Parameter, PagedListModel<EditParameterModel>, EditParameterModel, EditParameterModel>
{
public ParameterController(IRepository<Parameter> repo) : base(repo)
{
}
public override IQueryable<Parameter> Include(IQueryable<Parameter> 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);
}
}
}