ContactHandlers.cs
1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Parties.Contact;
namespace Sungero.Parties
{
partial class ContactServerHandlers
{
public override void BeforeSave(Sungero.Domain.BeforeSaveEventArgs e)
{
if (Functions.Contact.HaveDuplicates(_obj))
e.AddWarning(Sungero.Commons.Resources.DuplicateDetected, _obj.Info.Actions.ShowDuplicates);
}
public override void BeforeDelete(Sungero.Domain.BeforeDeleteEventArgs e)
{
if (!Commons.PublicFunctions.Module.IsAllExternalEntityLinksDeleted(_obj))
throw AppliedCodeException.Create(Commons.Resources.HasLinkedExternalEntities);
}
public override void Created(Sungero.Domain.CreatedEventArgs e)
{
ICompanyBase company;
if (CallContext.CalledFrom(CompanyBases.Info))
{
company = CompanyBases.Get(CallContext.GetCallerEntityId(CompanyBases.Info));
_obj.Company = company;
}
if (Contacts.Info.Properties.Company.TryGetFilter(out company))
{
_obj.Company = company;
}
}
}
}