|
@@ -0,0 +1,115 @@
|
|
1
|
+using Bizgaze.CRM;
|
|
2
|
+using Bizgaze.CRM.Visitors.Infos;
|
|
3
|
+using Bizgaze.CRM.Visitors.Managers;
|
|
4
|
+using System;
|
|
5
|
+using System.Collections.Generic;
|
|
6
|
+using System.Dynamic;
|
|
7
|
+using System.Linq;
|
|
8
|
+using System.Text;
|
|
9
|
+using System.Text.Json;
|
|
10
|
+using System.Threading.Tasks;
|
|
11
|
+using Unibase.Data;
|
|
12
|
+using Unibase.Data.Expressions;
|
|
13
|
+using Unibase.Data.Sql;
|
|
14
|
+using Unibase.Dependency;
|
|
15
|
+using Unibase.Platform.Apps.Managers;
|
|
16
|
+using Unibase.Platform.Data;
|
|
17
|
+using Unibase.Platform.Forms.Providers;
|
|
18
|
+using Unibase.Platform.Keys;
|
|
19
|
+
|
|
20
|
+namespace Bizgaze.CRM.Visitors.ActionProviders
|
|
21
|
+{
|
|
22
|
+ public class UpdateVisitorPreInvitePreAction : BaseFormActionProvider, IFormActionProvider
|
|
23
|
+ {
|
|
24
|
+ public string ControllerClass
|
|
25
|
+ {
|
|
26
|
+ get
|
|
27
|
+ {
|
|
28
|
+ return "Bizgaze.CRM.Visitors.ActionProviders.UpdateVisitorPreInvitePreAction";
|
|
29
|
+
|
|
30
|
+ }
|
|
31
|
+ }
|
|
32
|
+ public string FormActionName
|
|
33
|
+ {
|
|
34
|
+ get
|
|
35
|
+ {
|
|
36
|
+ return "UpdateVisitorPreInviteForm";
|
|
37
|
+ }
|
|
38
|
+ }
|
|
39
|
+ public string Description
|
|
40
|
+ {
|
|
41
|
+ get
|
|
42
|
+ {
|
|
43
|
+ return "Update Visitor Pre Invite PreAction";
|
|
44
|
+ }
|
|
45
|
+ }
|
|
46
|
+ public UniqueKey UniqueId
|
|
47
|
+ {
|
|
48
|
+ get
|
|
49
|
+ {
|
|
50
|
+ return Bizgaze.CRM.Actions.UpdateVisitorPreInvite;
|
|
51
|
+ }
|
|
52
|
+ }
|
|
53
|
+ public int ActionType
|
|
54
|
+ {
|
|
55
|
+ get
|
|
56
|
+ {
|
|
57
|
+ return (int)Unibase.Platform.Forms.Enums.FormActionProvider.PreAction;
|
|
58
|
+ }
|
|
59
|
+ }
|
|
60
|
+ public async Task<ActionResponse<FormActionResponse>> ExecuteAsync(ActionRequest request, FormActionProviderObject providerObject)
|
|
61
|
+ {
|
|
62
|
+ var IdValue = providerObject.IdValue;
|
|
63
|
+ var srequest = SelectRequest.FromRequest(request);
|
|
64
|
+ var obj = providerObject.RequestObject;
|
|
65
|
+ var returnresponse = new FormActionResponse();
|
|
66
|
+ var defaultPKValue = providerObject.DefaultPKValue;
|
|
67
|
+ var stageManager = Unibase.Dependency.DependencyConfig.Resolve<IStageManager>();
|
|
68
|
+ var visitorManager = Unibase.Dependency.DependencyConfig.Resolve<Bizgaze.CRM.Visitors.Managers.IVisitorManager>();
|
|
69
|
+ var dictObj = obj as IDictionary<string, dynamic>;
|
|
70
|
+ var MobileNumber = dictObj["mobilenumber"].ToString();
|
|
71
|
+ long visitorid = 0;
|
|
72
|
+ var visitorsinfo = await visitorManager.VisitorsbyMobileNumberAsync(srequest, MobileNumber);
|
|
73
|
+ Int32 refstatusid = 0;
|
|
74
|
+ var stageStatusName = "";
|
|
75
|
+ if (visitorsinfo.Result != null)
|
|
76
|
+ {
|
|
77
|
+ refstatusid = visitorsinfo.Result.RefStatusId;
|
|
78
|
+ visitorid = visitorsinfo.Result.VisitorId;
|
|
79
|
+
|
|
80
|
+ if (refstatusid == 3)
|
|
81
|
+ {
|
|
82
|
+ var agree = await visitorManager.VisitorAgreementAsync(request, visitorid);
|
|
83
|
+ stageStatusName = "CheckIn";
|
|
84
|
+ dictObj["visitorid"] = visitorid;
|
|
85
|
+ DateTime dates = DateTime.Now;
|
|
86
|
+ var installedAppId = visitorsinfo.Result.Installedappid;
|
|
87
|
+ var stage = await stageManager.GetStageByStageStatusAsync(srequest, installedAppId, stageStatusName);
|
|
88
|
+ var NewStageId = stage.Result.StageId;
|
|
89
|
+ var Updatecheckindate = new Update("bizgazecrm_visitors").Value("typeofvisitor", 1).Value("stageid", NewStageId).Value("checkindate", dates).Value("lastupdateddate", dates).Where(Exp.Eq("visitorid", visitorid));
|
|
90
|
+ await _repository.ExecuteAsync(request, Updatecheckindate);
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ }
|
|
94
|
+ else
|
|
95
|
+ {
|
|
96
|
+ return ActionResponse<FormActionResponse>.CreateErrorResponse("1", "visitor Not Found");
|
|
97
|
+ }
|
|
98
|
+ returnresponse = new FormActionResponse();
|
|
99
|
+ returnresponse.Obj = null;
|
|
100
|
+ returnresponse.PkValue = 0;
|
|
101
|
+ return ActionResponse<FormActionResponse>.CreateSuccessResponse("success", returnresponse);
|
|
102
|
+ }
|
|
103
|
+ public List<UniqueKey> AppliedApps
|
|
104
|
+ {
|
|
105
|
+ get
|
|
106
|
+ {
|
|
107
|
+ return new List<UniqueKey>() {
|
|
108
|
+ Bizgaze.CRM.Actions.UpdateVisitorBeenHere,
|
|
109
|
+ };
|
|
110
|
+ }
|
|
111
|
+ }
|
|
112
|
+
|
|
113
|
+ }
|
|
114
|
+}
|
|
115
|
+
|