Files
BeWoPlaner/ReportImp/AbwWeeger/Validation/ServiceRecordValidator.cs

56 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using BS.Shared;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
namespace AbwWeeger
{
public class BetreuwoServiceRecordValidator : ServiceRecordValidator
{
//public override string[] GetIgnoreServiceDescriptionsForOverlappingCheck()
//{
// return new[] {"Fehlkontakt"};
//}
public override List<ServiceRecordValidationResultDC> ValidateServiceRecord(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics,
int maxDaysEditServiceRecordsAllowed, IList<long> employeeOids, IList<long> cb2scOids)
{
var result = base.ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, cb2scOids);
foreach (var r in result)
{
if (r.ResultType == ServiceRecordValidationResult.Custom && r.Message.Contains("angegebenen Zeitraum abwesend"))
{
r.Message = r.Message.Replace("Möchten Sie trotzdem speichern?", "").Trim();
r.Allow = false;
}
}
return result;
}
public override ServiceRecordValidationResultDC CheckAbwesenheiten(ServiceRecordDC newServiceRecord, IList<ServiceRecord> allRecords, SupportConceptCostBearerRelDC reldc, decimal rd, bool isGroupRecord)
{
var newList = new List<ServiceRecord>();
Dictionary<long, bool> dict = new Dictionary<long, bool>();
if (allRecords != null)
{
foreach (var sr in allRecords)
{
if (!dict.ContainsKey(sr.Oid.Value))
{
newList.Add(sr);
dict.Add(sr.Oid.Value, true);
}
}
}
return base.CheckAbwesenheiten(newServiceRecord, newList, reldc, rd, isGroupRecord);
}
}
}