�@using DB_Pro;
@using System.Timers;
@inject Data.DataService DS;
<li>
@prospectRequested.BusinessName
<button class="btn btn-primary" @onclick="ShowPopup">Request</button>
</li>
<li>
@prospectRequested.PerformanceActivity.Description
</li>
@if (_show)
{
<h3>Chiedi a @receivingUser.Name di essere referenziato</h3>
<textarea rows="4" cols="50" @bind="@subject" bind:event="oninput">
Ciao @receivingUser.Name vorrei essere referenziato a @prospectRequested.BusinessName
</textarea>
<br>
<textarea @bind="@referenceReason" bind:event="oninput"
placeholder="Inserisci qui le motivazione per cui @prospectRequested.BusinessName dovrebbe essere interessata al tuo prodotto/servizio"></textarea>
<button class="btn btn-primary" @onclick="HidePopUp">Submit </button>
}
@if (_showconfirm)
{
<h6>Richiesta di referenza inviata con successo!</h6>
}
@code {
public bool _showconfirm { get; set; }
[Parameter]
public bool _show { get; set; }
[Parameter]
public User receivingUser { get; set; }
[Parameter]
public User askingUser { get; set; }
[Parameter]
public Prospect prospectRequested { get; set; }
public void HidePopUp()//here I call the method "StarTimer"
{
List<User> usersToSave = new List<User>();
usersToSave.Add(receivingUser);
usersToSave.Add(askingUser);
var newReq = CreateRefRequest(askingUser, receivingUser, prospectRequested, subject, referenceReason);
SaveRefRequest(usersToSave);
ShowRefReqConfirmedMsg();
StartTimer();
}
public void ShowPopup()
{
_show = true;
subject = $"Ciao {receivingUser.Name} vorrei essere referenziato a {prospectRequested.BusinessName}";
}
public void HideRefReq()
{
_show = false;
}
public void ShowRefReqConfirmedMsg()
{
_showconfirm = true;
}
string subject = "";
string referenceReason = "";
public Reference_Request CreateRefRequest(User applicant, User receiver, Prospect prospect, String subject, String referenceReason)
{
Reference_Request refRequest = new Reference_Request();
refRequest.Applicant = applicant;
refRequest.Receiver = receiver;
refRequest.Prospect = prospect;
refRequest.Subject = subject;
refRequest.ReferenceReason = referenceReason;
return refRequest;
}
public void SaveRefRequest(List<User> usersToSave)
{
DS.SaveToDisk(usersToSave);
}
public void hiderefreqConfirmPopUp(Object source, ElapsedEventArgs e)
{
//eventhandler
_show = false;
}
private Timer _timer;
private void StartTimer()
{
_timer = new Timer();
_timer.Interval = 3000;
_timer.Elapsed += hiderefreqConfirmPopUp;
}