using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Core;
|
using WIDESEA_Core.BaseServices;
|
using WIDESEA_Core.Enums;
|
using WIDESEA_IBasicRepository;
|
using WIDESEA_IBasicService;
|
using WIDESEA_Model.Models;
|
using WIDESEA_Core.Helper;
|
|
namespace WIDESEA_BasicService
|
{
|
public partial class RoadwayInfoService : ServiceBase<Dt_RoadwayInfo, IRoadwayInfoRepository>, IRoadwayInfoService
|
{
|
public RoadwayInfoService(IRoadwayInfoRepository BaseDal) : base(BaseDal)
|
{
|
}
|
|
public IRoadwayInfoRepository Repository => BaseDal;
|
|
public override WebResponseContent AddData(SaveModel saveModel)
|
{
|
Dt_RoadwayInfo roadwayInfo = saveModel.MainData.DicToModel<Dt_RoadwayInfo>();
|
return base.AddData(roadwayInfo);
|
}
|
|
public override WebResponseContent UpdateData(SaveModel saveModel)
|
{
|
return base.UpdateData(saveModel);
|
}
|
|
public override WebResponseContent DeleteData(object[] keys)
|
{
|
return base.DeleteData(keys);
|
}
|
|
public WebResponseContent RoadwayEnableStatus(int[] keys)
|
{
|
List<Dt_RoadwayInfo> roadwayInfos = Repository.QueryData(x => keys.Contains(x.Id));
|
roadwayInfos.ForEach(x =>
|
{
|
x.EnableStatus = EnableEnum.Enable.ObjToInt();
|
});
|
Repository.UpdateData(roadwayInfos);
|
|
return WebResponseContent.Instance.OK();
|
}
|
|
public WebResponseContent RoadwayDisableStatus(int[] keys)
|
{
|
List<Dt_RoadwayInfo> roadwayInfos = Repository.QueryData(x => keys.Contains(x.Id));
|
roadwayInfos.ForEach(x =>
|
{
|
x.EnableStatus = EnableEnum.Disable.ObjToInt();
|
});
|
Repository.UpdateData(roadwayInfos);
|
|
return WebResponseContent.Instance.OK();
|
}
|
|
/// <summary>
|
/// 修改巷道的禁用状态
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public WebResponseContent UpdateEnableStatus(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
List<Dt_RoadwayInfo> roadwayInfos = Repository.QueryData(x => saveModel.DelKeys.Contains(x.Id));
|
var values = Enum.GetValues(typeof(EnableStatusEnum));
|
var Index = saveModel.Extra.ObjToInt();
|
var EnableStatus = (EnableStatusEnum)values.GetValue(Index);
|
roadwayInfos.ForEach(x =>
|
{
|
x.EnableStatus = EnableStatus.ObjToInt();
|
});
|
Repository.UpdateData(roadwayInfos);
|
content.OK();
|
}
|
catch (Exception ex)
|
{
|
content.Error(ex.Message);
|
}
|
|
return content;
|
}
|
|
public WebResponseContent RoadwayEnableStatus(int key)
|
{
|
return RoadwayEnableStatus(new int[] { key });
|
}
|
|
public WebResponseContent RoadwayDisableStatus(int key)
|
{
|
return RoadwayDisableStatus(new int[] { key });
|
}
|
}
|
}
|