106 lines
3.9 KiB
C#
106 lines
3.9 KiB
C#
using AutoMapper;
|
|
using IRaCIS.Application.Interfaces;
|
|
using IRaCIS.Application.Contracts;
|
|
using IRaCIS.Core.Application.Filter;
|
|
using IRaCIS.Core.Infra.EFCore;
|
|
using IRaCIS.Core.Domain.Models;
|
|
using IRaCIS.Core.Infrastructure.Extention;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Panda.DynamicWebApi.Attributes;
|
|
|
|
namespace IRaCIS.Application.Services
|
|
{
|
|
[ ApiExplorerSettings(GroupName = "Financial")]
|
|
public class RankPriceService : BaseService, IRankPriceService
|
|
{
|
|
private readonly IRepository<RankPrice> _rankPriceRepository;
|
|
private readonly IRepository<ReviewerPayInformation> _reviewerPayInfoRepository;
|
|
|
|
|
|
public RankPriceService(IRepository<RankPrice> rankPriceRepository, IRepository<ReviewerPayInformation> reviewerPayInfoRepository,IMapper mapper)
|
|
{
|
|
_rankPriceRepository = rankPriceRepository;
|
|
_reviewerPayInfoRepository = reviewerPayInfoRepository;
|
|
|
|
}
|
|
|
|
[NonDynamicMethod]
|
|
public async Task<IResponseOutput> AddOrUpdateRankPrice(RankPriceCommand addOrUpdateModel, Guid userId)
|
|
{
|
|
if (addOrUpdateModel.Id == Guid.Empty|| addOrUpdateModel.Id ==null)
|
|
{
|
|
var rankPrice = _mapper.Map<RankPrice>(addOrUpdateModel);
|
|
rankPrice = await _rankPriceRepository.AddAsync(rankPrice);
|
|
if (await _rankPriceRepository.SaveChangesAsync())
|
|
{
|
|
return ResponseOutput.Ok(rankPrice.Id.ToString());
|
|
}
|
|
else
|
|
{
|
|
return ResponseOutput.NotOk();
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
var success =await _rankPriceRepository.BatchUpdateNoTrackingAsync(t => t.Id == addOrUpdateModel.Id, u => new RankPrice()
|
|
{
|
|
UpdateUserId = userId,
|
|
UpdateTime = DateTime.Now,
|
|
RefresherTraining=addOrUpdateModel.RefresherTraining,
|
|
RankName = addOrUpdateModel.RankName,
|
|
Timepoint = addOrUpdateModel.Timepoint,
|
|
TimepointIn24H = addOrUpdateModel.TimepointIn24H,
|
|
TimepointIn48H = addOrUpdateModel.TimepointIn48H,
|
|
Adjudication = addOrUpdateModel.Adjudication,
|
|
AdjudicationIn24H = addOrUpdateModel.AdjudicationIn24H,
|
|
AdjudicationIn48H = addOrUpdateModel.AdjudicationIn48H,
|
|
Global = addOrUpdateModel.Global,
|
|
Training = addOrUpdateModel.Training,
|
|
Downtime = addOrUpdateModel.Downtime
|
|
|
|
});
|
|
|
|
|
|
return ResponseOutput.Result(success);
|
|
}
|
|
}
|
|
|
|
|
|
[HttpDelete("{id:guid}")]
|
|
public async Task<IResponseOutput> DeleteRankPrice(Guid id)
|
|
{
|
|
|
|
if (await _reviewerPayInfoRepository.AnyAsync(t => t.RankId == id))
|
|
{
|
|
//---This title has been used by reviewer payment information
|
|
return ResponseOutput.NotOk(_localizer["RP_TitleUsedByRev"]);
|
|
}
|
|
|
|
var success = await _rankPriceRepository.BatchDeleteNoTrackingAsync(t => t.Id == id);
|
|
|
|
return ResponseOutput.Result(success);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取职称单价列表
|
|
/// </summary>
|
|
[HttpPost]
|
|
public async Task<PageOutput<RankPriceDTO>> GetRankPriceList(RankPriceQueryDTO inQuery)
|
|
{
|
|
var rankPriceQueryable = _rankPriceRepository.ProjectTo<RankPriceDTO>(_mapper.ConfigurationProvider);
|
|
return await rankPriceQueryable.ToPagedListAsync(inQuery);
|
|
|
|
}
|
|
|
|
|
|
public async Task<List<RankDic>> GetRankDic()
|
|
{
|
|
var rankQueryable = _rankPriceRepository.ProjectTo<RankDic>(_mapper.ConfigurationProvider);
|
|
return await rankQueryable.ToListAsync();
|
|
|
|
}
|
|
|
|
}
|
|
}
|