|
|
|
@ -2,10 +2,13 @@ using Infrastructure.Application;
|
|
|
|
|
using Infrastructure.Application.Entites.Settings;
|
|
|
|
|
using Infrastructure.Application.Models;
|
|
|
|
|
using Infrastructure.Application.Services.Settings;
|
|
|
|
|
using Infrastructure.Data;
|
|
|
|
|
using Infrastructure.Extensions;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Serialization;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
@ -15,15 +18,17 @@ namespace Infrastructure.Web.Mvc
|
|
|
|
|
[Area("Admin")]
|
|
|
|
|
public class SettingController : BaseController
|
|
|
|
|
{
|
|
|
|
|
private readonly IRepository<Setting> _settingRepo;
|
|
|
|
|
private readonly ISettingService _settingService;
|
|
|
|
|
|
|
|
|
|
public SettingController(ISettingService settingService)
|
|
|
|
|
public SettingController(IRepository<Setting> settingRepo,ISettingService settingService)
|
|
|
|
|
{
|
|
|
|
|
this._settingRepo = settingRepo;
|
|
|
|
|
this._settingService = settingService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Authorize(Roles = "Read-Setting")]
|
|
|
|
|
public IActionResult Index(PagedList<Setting> model)
|
|
|
|
|
public IActionResult Index(PagedListModel<EditSettingModel> model)
|
|
|
|
|
{
|
|
|
|
|
if (model is null)
|
|
|
|
|
{
|
|
|
|
@ -33,8 +38,18 @@ namespace Infrastructure.Web.Mvc
|
|
|
|
|
model.TotalCount = query.Count();
|
|
|
|
|
model.List.AddRange(query.Skip(model.PageSize * (model.PageIndex - 1))
|
|
|
|
|
.Take(model.PageSize)
|
|
|
|
|
.ToList());
|
|
|
|
|
return View(model);
|
|
|
|
|
.ToList()
|
|
|
|
|
.Select(o=>o.To<EditSettingModel>()));
|
|
|
|
|
ViewData.SelectList(o=>model.Query.Type,()=>this.GetSelectList<SettingType>(model.Query.Type));
|
|
|
|
|
return Result(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public virtual IActionResult Details(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var entity = this._settingRepo.ReadOnlyTable().FirstOrDefault(o => o.Id == id);
|
|
|
|
|
var model = entity.To<EditSettingModel>();
|
|
|
|
|
return Result(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Authorize(Roles = "Edit-Setting")]
|
|
|
|
@ -124,5 +139,20 @@ namespace Infrastructure.Web.Mvc
|
|
|
|
|
{
|
|
|
|
|
return PartialView("_Ajax", new EditSettingModel { Type = type });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)]
|
|
|
|
|
private IActionResult Result(object model)
|
|
|
|
|
{
|
|
|
|
|
if (this.Request.Headers["accept"].ToString().Contains("json", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return Json(new
|
|
|
|
|
{
|
|
|
|
|
schema = this.GetJsonSchema<EditSettingModel>(),
|
|
|
|
|
model,
|
|
|
|
|
data = ViewData
|
|
|
|
|
}, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
|
|
|
|
|
}
|
|
|
|
|
return View(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|