|
@@ -1,6 +1,7 @@
|
1
|
1
|
using Bizgaze.CRM;
|
2
|
2
|
using Bizgaze.CRM.Visitors.Infos;
|
3
|
3
|
using Bizgaze.CRM.Visitors.Managers;
|
|
4
|
+using MongoDB.Bson;
|
4
|
5
|
using System;
|
5
|
6
|
using System.Collections.Generic;
|
6
|
7
|
using System.Dynamic;
|
|
@@ -17,6 +18,7 @@ using Unibase.Platform.Data;
|
17
|
18
|
using Unibase.Platform.Forms.Providers;
|
18
|
19
|
using Unibase.Platform.Keys;
|
19
|
20
|
using Unibase.Platform.Tenants.Localization;
|
|
21
|
+using System.Text.Json;
|
20
|
22
|
|
21
|
23
|
namespace Bizgaze.CRM.Visitors.ActionProviders
|
22
|
24
|
{
|
|
@@ -68,6 +70,7 @@ namespace Bizgaze.CRM.Visitors.ActionProviders
|
68
|
70
|
var stageManager = Unibase.Dependency.DependencyConfig.Resolve<IStageManager>();
|
69
|
71
|
var visitorManager = Unibase.Dependency.DependencyConfig.Resolve<Bizgaze.CRM.Visitors.Managers.IVisitorManager>();
|
70
|
72
|
var dictObj = obj as IDictionary<string, dynamic>;
|
|
73
|
+ var visitorItems = dictObj.ContainsKey("VisitorItems") ? dictObj["VisitorItems"] : null;
|
71
|
74
|
var MobileNumber = dictObj["mobilenumber"].ToString();
|
72
|
75
|
var employeeId = Convert.ChangeType(dictObj["employeeid"].ToString(), typeof(long));
|
73
|
76
|
var cityId = Convert.ChangeType(dictObj["cityid"].ToString(), typeof(long));
|
|
@@ -91,7 +94,6 @@ namespace Bizgaze.CRM.Visitors.ActionProviders
|
91
|
94
|
stageStatusName = "CheckIn";
|
92
|
95
|
}
|
93
|
96
|
var code = visitorsinfo.Result.Code;
|
94
|
|
-
|
95
|
97
|
var agreement = visitorsinfo.Result.Agreement;
|
96
|
98
|
visitorsinfo.Result.Agreement = agreement;
|
97
|
99
|
dictObj["agreement"] = true;
|
|
@@ -114,7 +116,6 @@ namespace Bizgaze.CRM.Visitors.ActionProviders
|
114
|
116
|
IsExcludeFromAudit = false,
|
115
|
117
|
Id = 0,
|
116
|
118
|
};
|
117
|
|
-
|
118
|
119
|
dynamic visitor = new Dictionary<string, object>();
|
119
|
120
|
visitor.Add("createdby", srequest.Identity.UserId);
|
120
|
121
|
visitor.Add("createddate", DateTime.Now);
|
|
@@ -125,24 +126,22 @@ namespace Bizgaze.CRM.Visitors.ActionProviders
|
125
|
126
|
visitor.Add("contactid", contactid);
|
126
|
127
|
visitor.Add("code", visitorsinfo.Result.Code);
|
127
|
128
|
visitor.Add("agreement", true);
|
128
|
|
- visitor.Add("employeeid", employeeId);
|
129
|
129
|
visitor.Add("seriesid", visitorsinfo.Result.SeriesId);
|
130
|
130
|
visitor.Add("stageid", visitorsinfo.Result.StageId);
|
131
|
131
|
visitor.Add("tenantid", visitorsinfo.Result.TenantId);
|
132
|
132
|
visitor.Add("installedappid", visitorsinfo.Result.Installedappid);
|
133
|
133
|
visitor.Add("fullname", visitorsinfo.Result.FullName);
|
134
|
134
|
visitor.Add("futureinvitation", visitorsinfo.Result.FutureInvitation);
|
|
135
|
+ visitor.Add("employeeid", employeeId);
|
135
|
136
|
visitor.Add("cityid", cityId);
|
136
|
137
|
visitor.Add("purposeofvisit", purposeofvisit);
|
137
|
138
|
visitor.Add("title", visitorsinfo.Result.Title);
|
138
|
139
|
visitor.Add("visitortype", visitorsinfo.Result.VisitorType);
|
139
|
140
|
var response = await _repository.SaveAsync(request, vistoroptions, visitor);
|
140
|
|
-
|
141
|
141
|
if (response.Status == ResponseStatus.Error)
|
142
|
142
|
{
|
143
|
143
|
return ActionResponse<FormActionResponse>.CreateErrorResponse("1", "Visitor Check Out Data Not Saved");
|
144
|
144
|
}
|
145
|
|
-
|
146
|
145
|
var _visitorId = Convert.ToInt64(response.Result["_Id"].ToString());
|
147
|
146
|
var vistoroptions1 = new EntityOptions()
|
148
|
147
|
{
|
|
@@ -169,10 +168,37 @@ namespace Bizgaze.CRM.Visitors.ActionProviders
|
169
|
168
|
var response1 = await _repository.SaveAsync(request, vistoroptions1, visitor1);
|
170
|
169
|
if (response1.Status == ResponseStatus.Error)
|
171
|
170
|
{
|
172
|
|
-
|
173
|
171
|
return ActionResponse<FormActionResponse>.CreateErrorResponse("1", "Visitor Check Out Data Not Saved");
|
174
|
172
|
}
|
175
|
|
-
|
|
173
|
+ if (dictObj.ContainsKey("VisitorItems"))
|
|
174
|
+ {
|
|
175
|
+ var Items = Convert.ChangeType(dictObj["VisitorItems"].ToString(), typeof(object)).ToString();
|
|
176
|
+ var deserializeObj = System.Text.Json.JsonSerializer.Deserialize<List<Dictionary<string, object>>>(Items);
|
|
177
|
+ var visitoritem = deserializeObj[0]["visitoritemname"].ToString();
|
|
178
|
+ var serial = deserializeObj[0]["serialnumber"].ToString();
|
|
179
|
+ var quantity = Convert.ToInt64(deserializeObj[0]["quantity"].ToString());
|
|
180
|
+ var brand = deserializeObj[0]["brand"].ToString();
|
|
181
|
+ var vistoroptions2 = new EntityOptions()
|
|
182
|
+ {
|
|
183
|
+ IsIdentity = true,
|
|
184
|
+ IsNewEntity = true,
|
|
185
|
+ TableName = "bizgazecrm_visitoritems",
|
|
186
|
+ PkColumn = "visitoritemid",
|
|
187
|
+ IsExcludeFromAudit = false,
|
|
188
|
+ Id = 0,
|
|
189
|
+ };
|
|
190
|
+ dynamic visitor2 = new Dictionary<string, object>();
|
|
191
|
+ visitor2.Add("visitorid", _visitorId);
|
|
192
|
+ visitor2.Add("visitoritemname", visitoritem);
|
|
193
|
+ visitor2.Add("quantity", quantity);
|
|
194
|
+ visitor2.Add("brand", brand);
|
|
195
|
+ visitor2.Add("serialnumber", serial);
|
|
196
|
+ var response2 = await _repository.SaveAsync(request, vistoroptions2, visitor2);
|
|
197
|
+ if (response2.Status == ResponseStatus.Error)
|
|
198
|
+ {
|
|
199
|
+ return ActionResponse<FormActionResponse>.CreateErrorResponse("1", "Visitor Check Out Data Not Saved");
|
|
200
|
+ }
|
|
201
|
+ }
|
176
|
202
|
var lastdate = visitorsinfo.Result.LastUpdatedDate;
|
177
|
203
|
visitorsinfo.Result.LastUpdatedDate = DateTime.Now;
|
178
|
204
|
var installedAppId = visitorsinfo.Result.Installedappid;
|
|
@@ -186,8 +212,6 @@ namespace Bizgaze.CRM.Visitors.ActionProviders
|
186
|
212
|
{
|
187
|
213
|
return ActionResponse<FormActionResponse>.CreateErrorResponse("1", "visitor Not Found");
|
188
|
214
|
}
|
189
|
|
- returnresponse = new FormActionResponse();
|
190
|
|
- returnresponse.Obj = dictObj as ExpandoObject;
|
191
|
215
|
returnresponse.PkValue = defaultPKValue;
|
192
|
216
|
return ActionResponse<FormActionResponse>.CreateSuccessResponse("success", returnresponse);
|
193
|
217
|
}
|
|
@@ -200,7 +224,6 @@ namespace Bizgaze.CRM.Visitors.ActionProviders
|
200
|
224
|
};
|
201
|
225
|
}
|
202
|
226
|
}
|
203
|
|
-
|
204
|
227
|
}
|
205
|
228
|
}
|
206
|
229
|
|