parent
0a7b8a2990
commit
181a760957
@ -1,6 +1,6 @@
|
||||
@{var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !pm.HideSurroundingHtml && !pm.IsComplexType && !pm.IsCollectionType && pm.PropertyName != "Id").ToList();
|
||||
foreach (var prop in props)
|
||||
{
|
||||
<td>@Html.Display(prop.PropertyName, prop.DataTypeName ?? prop.TemplateHint)</td>
|
||||
<td style="max-width:10em;">@Html.Display(prop.PropertyName, prop.DataTypeName ?? prop.TemplateHint)</td>
|
||||
}
|
||||
}
|
@ -1,31 +1,41 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Application.Domain.Entities;
|
||||
using Infrastructure.Application;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Application.Models
|
||||
{
|
||||
[Display(Name = "数据")]
|
||||
public class EditDataModel : EditModel
|
||||
{
|
||||
[Display(Name = "类型")]
|
||||
[Required(ErrorMessage = nameof(RequiredAttribute))]
|
||||
public DeviceDataType Type { get; set; }
|
||||
|
||||
[Display(Name = "名称")]
|
||||
[Required(ErrorMessage = nameof(RequiredAttribute))]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Display(Name = "键")]
|
||||
[Required(ErrorMessage = nameof(RequiredAttribute))]
|
||||
[ReadOnly(true)]
|
||||
public string Key { get; set; }
|
||||
|
||||
[Display(Name = "值")]
|
||||
public string Value { get; set; }
|
||||
|
||||
[Display(Name = "名称")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Display(Name = "类型")]
|
||||
public DeviceDataType Type { get; set; }
|
||||
|
||||
[Display(Name = "单位")]
|
||||
public string Unit { get; set; }
|
||||
|
||||
[Display(Name = "描述")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[Display(Name = "时间戳")]
|
||||
public long Timestamp { get; set; }
|
||||
|
||||
[Display(Name = "隐藏")]
|
||||
public bool Hidden { get; set; }
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
[ScaffoldColumn(true)]
|
||||
public string DeviceNumber { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using Infrastructure.Application;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Application.Models
|
||||
{
|
||||
[Display(Name = "产品")]
|
||||
public class EditProductModel : EditModel
|
||||
{
|
||||
[Display(Name = "产品名称")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Display(Name = "产品型号")]
|
||||
public string Number { get; set; }
|
||||
|
||||
[Display(Name = "图标")]
|
||||
public string Icon { get; set; }
|
||||
|
||||
[Display(Name = "ApiJson")]
|
||||
public string ApiJson { get; set; }
|
||||
|
||||
[Display(Name = "产品分类")]
|
||||
public string CategoryName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
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;
|
||||
}
|
||||
|
||||
public override void ToDisplayModel(Product entity, EditProductModel model)
|
||||
{
|
||||
this.ToModel(entity, model);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue