VisitorPreInvitePreAction.cs Changes
This commit is contained in:
@@ -0,0 +1,115 @@
|
|||||||
|
using Bizgaze.CRM;
|
||||||
|
using Bizgaze.CRM.Visitors.Infos;
|
||||||
|
using Bizgaze.CRM.Visitors.Managers;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Unibase.Data;
|
||||||
|
using Unibase.Data.Expressions;
|
||||||
|
using Unibase.Data.Sql;
|
||||||
|
using Unibase.Dependency;
|
||||||
|
using Unibase.Platform.Apps.Managers;
|
||||||
|
using Unibase.Platform.Data;
|
||||||
|
using Unibase.Platform.Forms.Providers;
|
||||||
|
using Unibase.Platform.Keys;
|
||||||
|
|
||||||
|
namespace Bizgaze.CRM.Visitors.ActionProviders
|
||||||
|
{
|
||||||
|
public class UpdateVisitorPreInvitePreAction : BaseFormActionProvider, IFormActionProvider
|
||||||
|
{
|
||||||
|
public string ControllerClass
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Bizgaze.CRM.Visitors.ActionProviders.UpdateVisitorPreInvitePreAction";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string FormActionName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "UpdateVisitorPreInviteForm";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Update Visitor Pre Invite PreAction";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public UniqueKey UniqueId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Bizgaze.CRM.Actions.UpdateVisitorPreInvite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int ActionType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (int)Unibase.Platform.Forms.Enums.FormActionProvider.PreAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task<ActionResponse<FormActionResponse>> ExecuteAsync(ActionRequest request, FormActionProviderObject providerObject)
|
||||||
|
{
|
||||||
|
var IdValue = providerObject.IdValue;
|
||||||
|
var srequest = SelectRequest.FromRequest(request);
|
||||||
|
var obj = providerObject.RequestObject;
|
||||||
|
var returnresponse = new FormActionResponse();
|
||||||
|
var defaultPKValue = providerObject.DefaultPKValue;
|
||||||
|
var stageManager = Unibase.Dependency.DependencyConfig.Resolve<IStageManager>();
|
||||||
|
var visitorManager = Unibase.Dependency.DependencyConfig.Resolve<Bizgaze.CRM.Visitors.Managers.IVisitorManager>();
|
||||||
|
var dictObj = obj as IDictionary<string, dynamic>;
|
||||||
|
var MobileNumber = dictObj["mobilenumber"].ToString();
|
||||||
|
long visitorid = 0;
|
||||||
|
var visitorsinfo = await visitorManager.VisitorsbyMobileNumberAsync(srequest, MobileNumber);
|
||||||
|
Int32 refstatusid = 0;
|
||||||
|
var stageStatusName = "";
|
||||||
|
if (visitorsinfo.Result != null)
|
||||||
|
{
|
||||||
|
refstatusid = visitorsinfo.Result.RefStatusId;
|
||||||
|
visitorid = visitorsinfo.Result.VisitorId;
|
||||||
|
|
||||||
|
if (refstatusid == 3)
|
||||||
|
{
|
||||||
|
var agree = await visitorManager.VisitorAgreementAsync(request, visitorid);
|
||||||
|
stageStatusName = "CheckIn";
|
||||||
|
dictObj["visitorid"] = visitorid;
|
||||||
|
DateTime dates = DateTime.Now;
|
||||||
|
var installedAppId = visitorsinfo.Result.Installedappid;
|
||||||
|
var stage = await stageManager.GetStageByStageStatusAsync(srequest, installedAppId, stageStatusName);
|
||||||
|
var NewStageId = stage.Result.StageId;
|
||||||
|
var Updatecheckindate = new Update("bizgazecrm_visitors").Value("typeofvisitor", 1).Value("stageid", NewStageId).Value("checkindate", dates).Value("lastupdateddate", dates).Where(Exp.Eq("visitorid", visitorid));
|
||||||
|
await _repository.ExecuteAsync(request, Updatecheckindate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ActionResponse<FormActionResponse>.CreateErrorResponse("1", "visitor Not Found");
|
||||||
|
}
|
||||||
|
returnresponse = new FormActionResponse();
|
||||||
|
returnresponse.Obj = null;
|
||||||
|
returnresponse.PkValue = 0;
|
||||||
|
return ActionResponse<FormActionResponse>.CreateSuccessResponse("success", returnresponse);
|
||||||
|
}
|
||||||
|
public List<UniqueKey> AppliedApps
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new List<UniqueKey>() {
|
||||||
|
Bizgaze.CRM.Actions.UpdateVisitorBeenHere,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user