333 lines
12 KiB
C#
333 lines
12 KiB
C#
|
|
using CloudBuilder.Core.DatabaseAccessor;
|
|
using CloudBuilder.Core.Policy;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Transactions;
|
|
using CloudBuilder.Core.Service;
|
|
using CloudBuilder.Master.Service;
|
|
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
|
using CloudBuilder.Master.Data;
|
|
using System;
|
|
using CloudBuilder.Master.SearchCriteria;
|
|
using Microsoft.AspNetCore.Http;
|
|
using CloudBuilder.Master.Entity;
|
|
|
|
namespace CloudBuilder.Web.Entry.Controllers.Master
|
|
{
|
|
[Authorize(AuthorizePolicy.PERMISSION)]
|
|
[ApiController]
|
|
[Route("[controller]/[action]")]
|
|
public class FamilyGroupController : ControllerBase
|
|
{
|
|
private readonly IApplicationService service;
|
|
private readonly IFamilyGroupService familyGroupService;
|
|
|
|
public FamilyGroupController(IApplicationService service, IFamilyGroupService familyGroupService)
|
|
{
|
|
this.service = service;
|
|
this.familyGroupService= familyGroupService;
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Find")]
|
|
[HttpPost]
|
|
public dynamic FindByKey(string key)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = familyGroupService.FindByKey(key);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Find")]
|
|
[HttpPost]
|
|
public dynamic FindBySearchCriteria(FamilyGroupSearchCriteria criteria)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = familyGroupService.FindBySearchCriteria(criteria);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Find")]
|
|
[HttpPost]
|
|
public dynamic FindFamilyUserBySearchCriteria(FamilyGroupManagerUserSearchCriteria criteria)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = familyGroupService.FindFamilyUserBySearchCriteria(criteria);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Find")]
|
|
[HttpPost]
|
|
public dynamic FamilyFolderFavoriteBySearchCriteria(FamilyGroupManagerUserSearchCriteria criteria)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = familyGroupService.FamilyFolderFavoriteBySearchCriteria(criteria);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Print")]
|
|
[HttpPost]
|
|
public dynamic PrintBySearchCriteria(FamilyGroupSearchCriteria criteria)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = familyGroupService.PrintBySearchCriteria(criteria);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Insert")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic Insert(FamilyGroupData data)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = familyGroupService.Insert(data);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Update")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic Update(FamilyGroupData data)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = familyGroupService.Update(data);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Delete")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic Delete(string key){
|
|
try
|
|
{
|
|
familyGroupService.Delete(key);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Update")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic InsertFamilyGroupManager(FamilyGroupManagerEntity manager){
|
|
try
|
|
{
|
|
familyGroupService.InsertFamilyGroupManager(manager);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Insert")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic InsertFamilyGroupPermission(FamilyGroupPermissionEntity[] managers){
|
|
try
|
|
{
|
|
familyGroupService.InsertFamilyGroupPermission(managers);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Update")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic UpdateFamilyGroupManager(FamilyGroupManagerEntity manager){
|
|
try
|
|
{
|
|
familyGroupService.UpdateFamilyGroupManager(manager);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Update")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic DeleteFamilyGroupManager(FamilyGroupManagerEntity manager){
|
|
try
|
|
{
|
|
familyGroupService.DeleteFamilyGroupManager(manager);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Insert")]
|
|
[HttpPost]
|
|
public dynamic InsertFamilyFolderFavorite(string folderName){
|
|
try
|
|
{
|
|
familyGroupService.InsertFamilyFolderFavorite(folderName);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Update")]
|
|
[HttpPost]
|
|
public dynamic DeleteFamilyFolderFavorite(string folderName){
|
|
try
|
|
{
|
|
familyGroupService.DeleteFamilyFolderFavorite(folderName);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "FamilyGroup", operate: "Update")]
|
|
[HttpPost]
|
|
public dynamic DeleteFamilyFolderFavorites(FamilyFolderFavoriteEntity[] familyFolderFavorites){
|
|
try
|
|
{
|
|
familyGroupService.DeleteFamilyFolderFavorites(familyFolderFavorites);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
} |