Files
BeWoPlaner/Service/DCEntityMapper/MandatorDC_Mandator.cs

119 lines
3.7 KiB
C#

using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
using System;
namespace BeWo.Service.DCEntityMapper
{
public class MandatorDC_Mandator : AbstractIDCEntityMapper<Mandator, MandatorDC>
{
public override MandatorDC MergeWithDC(Mandator from, MandatorDC to)
{
to.MandatorOid = from.Oid;
to.MandatorVersion = from.Version;
to.Website = from.Website;
to.Name = from.Name;
to.ClientId = from.ClientId;
to.BeWoClientType = from.BeWoClientType;
to.Country = from.Country;
to.State = from.State;
to.Town = from.Town;
to.PostalCode = from.PostalCode;
to.Street = from.Street;
to.Settings = from.Settings;
to.RssFeedUrl = from.RssFeedUrl;
to.IsSchedulerAllowed = from.IsSchedulerAllowed;
to.IsMedicationAllowed = from.IsMedicationAllowed;
to.BankAccount = MapperFactory.BankAccountDC_BankAccount.MapToNewDC(from.BankAccount, false);
to.AllowSbd = !string.IsNullOrEmpty(to.ClientId) && to.ClientId == "SBD";
to.ShowGkvBzEinzel = from.ShowGkvBzEinzel;
to.ShowGkvBzUrbelege = from.ShowGkvBzUrbelege;
to.ColorSendUrbelege = from.ColorSendUrbelege;
to.ColorWaitTooLong = from.ColorWaitTooLong;
#if DEBUG
//pDataContract.AllowSbd = true;
#endif
to.Apikey = from.Apikey;
to.IKLeistungserbringer = from.IKLeistungserbringer;
var can_edit = GetCanEditIKLeistungserbringer();
to.CanEditIKLeistungserbringer = can_edit;
to.CanEditIKLeistungserbringerTooltip = can_edit ? null :
"Mit dem Senden mind. einer GKV Abrechnung haben Sie sich bereits\n" +
"mit dieser IK bei uns registiert. Bei Änderungswunsch wenden Sie\n" +
"sich bitte an unseren Support.";
if (from.SoziotherapieAnsprechpartner is object)
to.SoziotherapieAnsprechpartner = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(from.SoziotherapieAnsprechpartner);
if (from.Logo is object)
to.Logo = MapperFactory.ImageDC_Image.MapToNewDC(from.Logo);
return to;
}
public override Mandator MergeWithEntity(MandatorDC from, Mandator to)
{
this.ConcurrencyCheck(from.MandatorVersion, to);
to.Name = from.Name;
to.Website = from.Website.ToNullIfEmpty();
to.ClientId = from.ClientId;
to.BeWoClientType = from.BeWoClientType;
to.Country = from.Country;
to.State = from.State;
to.Town = from.Town;
to.PostalCode = from.PostalCode;
to.Street = from.Street;
to.Settings = from.Settings;
to.RssFeedUrl = from.RssFeedUrl;
to.IsSchedulerAllowed = from.IsSchedulerAllowed;
to.IsMedicationAllowed = from.IsMedicationAllowed;
to.Apikey = from.Apikey;
to.IKLeistungserbringer = from.IKLeistungserbringer.ToNullIfEmpty();
to.BankAccount = MapperFactory.BankAccountDC_BankAccount.MergeWithEntity(from.BankAccount, to.BankAccount, false);
to.SoziotherapieAnsprechpartner = MapperFactory.CompactEmployeeDC_Employee.MergeWithEntity(from.SoziotherapieAnsprechpartner, to.SoziotherapieAnsprechpartner, false);
to.Logo = MapperFactory.ImageDC_Image.MergeWithEntity(from.Logo, to.Logo, false);
to.ShowGkvBzEinzel = from.ShowGkvBzEinzel;
to.ShowGkvBzUrbelege = from.ShowGkvBzUrbelege;
to.ColorSendUrbelege = from.ColorSendUrbelege;
to.ColorWaitTooLong = from.ColorWaitTooLong;
return to;
}
protected override bool AreDCAndEntityEqual(MandatorDC pDC, Mandator pEntity)
{
if (pDC.MandatorOid == null)
{
return false;
}
return pDC.MandatorOid == pEntity.Oid;
}
private bool GetCanEditIKLeistungserbringer()
{
try
{
var row_count = DAOFactory.GenericDAO.GetRowCount<GkvTransferProtokoll>();
return row_count == 0;
}
catch (Exception)
{
}
return true;
}
}
}