preparing to feed abstract
test should run ok [modulo config]
This commit is contained in:
@ -65,7 +65,7 @@ namespace Yavsc.Models.Billing
|
||||
public DateTime? ValidationDate {get; set;}
|
||||
|
||||
|
||||
[Display(Name="Montant prévisionel de la préstation")]
|
||||
[Display(Name="Previsional")]
|
||||
public decimal? Previsional { get; set; }
|
||||
/// <summary>
|
||||
/// The bill
|
||||
|
@ -1,162 +0,0 @@
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using MailKit.Net.Smtp;
|
||||
using MimeKit;
|
||||
using MailKit.Security;
|
||||
using System;
|
||||
using Yavsc.Models.Messaging;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Google.Messaging;
|
||||
using System.Collections.Generic;
|
||||
using Yavsc.Models.Haircut;
|
||||
using Yavsc.Interfaces.Workflow;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Server.Helpers;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Yavsc.Abstract.Manage;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
// This class is used by the application to send Email and SMS
|
||||
// when you turn on two-factor authentication in ASP.NET Identity.
|
||||
// For more details see this link http://go.microsoft.com/fwlink/?LinkID=532713
|
||||
public class MessageSender : IEmailSender, IGoogleCloudMessageSender
|
||||
{
|
||||
private ILogger _logger;
|
||||
SiteSettings siteSettings;
|
||||
SmtpSettings smtpSettings;
|
||||
GoogleAuthSettings googleSettings;
|
||||
|
||||
public MessageSender(
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptions<SiteSettings> sitesOptions,
|
||||
IOptions<SmtpSettings> smtpOptions,
|
||||
IOptions<GoogleAuthSettings> googleOptions
|
||||
)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger<MessageSender>();
|
||||
siteSettings = sitesOptions?.Value;
|
||||
smtpSettings = smtpOptions?.Value;
|
||||
googleSettings = googleOptions?.Value;
|
||||
}
|
||||
|
||||
public async Task <MessageWithPayloadResponse> NotifyEvent<Event>
|
||||
( IEnumerable<string> regids, Event ev)
|
||||
where Event : IEvent
|
||||
{
|
||||
if (ev == null)
|
||||
throw new Exception("Spécifier un évènement");
|
||||
|
||||
if (ev.Sender == null)
|
||||
throw new Exception("Spécifier un expéditeur");
|
||||
|
||||
if (regids == null )
|
||||
throw new NotImplementedException("Notify & No GCM reg ids");
|
||||
var raa = regids.ToArray();
|
||||
if (raa.Length<1)
|
||||
throw new NotImplementedException("No GCM reg ids");
|
||||
var msg = new MessageWithPayload<Event>()
|
||||
{
|
||||
data = ev,
|
||||
registration_ids = regids.ToArray()
|
||||
};
|
||||
_logger.LogInformation("Sendding to Google : "+JsonConvert.SerializeObject(msg));
|
||||
try {
|
||||
using (var m = new SimpleJsonPostMethod("https://gcm-http.googleapis.com/gcm/send",$"key={googleSettings.ApiKey}")) {
|
||||
return await m.Invoke<MessageWithPayloadResponse>(msg);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new Exception ("Quelque chose s'est mal passé à l'envoi",ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="googleSettings"></param>
|
||||
/// <param name="registrationId"></param>
|
||||
/// <param name="ev"></param>
|
||||
/// <returns>a MessageWithPayloadResponse,
|
||||
/// <c>bool somethingsent = (response.failure == 0 && response.success > 0)</c>
|
||||
/// </returns>
|
||||
public async Task<MessageWithPayloadResponse> NotifyBookQueryAsync( IEnumerable<string> registrationIds, RdvQueryEvent ev)
|
||||
{
|
||||
return await NotifyEvent<RdvQueryEvent>(registrationIds, ev);
|
||||
}
|
||||
|
||||
public async Task<MessageWithPayloadResponse> NotifyEstimateAsync(IEnumerable<string> registrationIds, EstimationEvent ev)
|
||||
{
|
||||
return await NotifyEvent<EstimationEvent>(registrationIds, ev);
|
||||
}
|
||||
|
||||
public async Task<MessageWithPayloadResponse> NotifyHairCutQueryAsync(
|
||||
IEnumerable<string> registrationIds, HairCutQueryEvent ev)
|
||||
{
|
||||
return await NotifyEvent<HairCutQueryEvent>(registrationIds, ev);
|
||||
}
|
||||
|
||||
public Task<EmailSentViewModel> SendEmailAsync(string username, string email, string subject, string message)
|
||||
{
|
||||
EmailSentViewModel model = new EmailSentViewModel{ EMail = email };
|
||||
try
|
||||
{
|
||||
MimeMessage msg = new MimeMessage();
|
||||
msg.From.Add(new MailboxAddress(
|
||||
siteSettings.Owner.Name,
|
||||
siteSettings.Owner.EMail));
|
||||
msg.To.Add(new MailboxAddress(username, email));
|
||||
msg.Body = new TextPart("plain")
|
||||
{
|
||||
Text = message
|
||||
};
|
||||
msg.Subject = subject;
|
||||
msg.MessageId = MimeKit.Utils.MimeUtils.GenerateMessageId(
|
||||
siteSettings.Authority
|
||||
);
|
||||
using (SmtpClient sc = new SmtpClient())
|
||||
{
|
||||
sc.Connect(
|
||||
smtpSettings.Host,
|
||||
smtpSettings.Port,
|
||||
SecureSocketOptions.None);
|
||||
sc.Send(msg);
|
||||
model.MessageId = msg.MessageId;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
model.Sent = false;
|
||||
model.ErrorMessage = ex.Message;
|
||||
return Task.FromResult<EmailSentViewModel>(model);
|
||||
}
|
||||
return Task.FromResult(model);
|
||||
}
|
||||
|
||||
public Task<bool> ValidateAsync(string purpose, string token, UserManager<ApplicationUser> manager, ApplicationUser user)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<MessageWithPayloadResponse> NotifyAsync(
|
||||
IEnumerable<string> regids, IEvent yaev)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
/* SMS with Twilio:
|
||||
public Task SendSmsAsync(TwilioSettings twilioSettigns, string number, string message)
|
||||
{
|
||||
var Twilio = new TwilioRestClient(twilioSettigns.AccountSID, twilioSettigns.Token);
|
||||
var result = Twilio.SendMessage( twilioSettigns.SMSAccountFrom, number, message);
|
||||
// Status is one of Queued, Sending, Sent, Failed or null if the number is not valid
|
||||
Trace.TraceInformation(result.Status);
|
||||
// Twilio doesn't currently have an async API, so return success.
|
||||
|
||||
return Task.FromResult(result.Status != "Failed");
|
||||
|
||||
} */
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
|
||||
namespace Yavsc.ViewModels.Account
|
||||
{
|
||||
@ -49,6 +48,13 @@ namespace Yavsc.ViewModels.Account
|
||||
/// Lists external identity provider descriptions.
|
||||
/// </summary>
|
||||
/// <returns>an enumeration of the descriptions.</returns>
|
||||
public IEnumerable<AuthenticationDescription> ExternalProviders { get; set; }
|
||||
public IEnumerable<YaAuthenticationDescription> ExternalProviders { get; set; }
|
||||
}
|
||||
|
||||
public class YaAuthenticationDescription {
|
||||
public string DisplayName { get; set; }
|
||||
public string AuthenticationScheme { get; set; }
|
||||
|
||||
public IDictionary<string,object> Items { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
namespace Yavsc.Models.Auth
|
||||
{
|
||||
public class Me : IApplicationUser {
|
||||
public Me(ApplicationUser user)
|
||||
public Me(string userId, string userName, string email, string avatar, ILocation address, string gCalId)
|
||||
{
|
||||
Id = user.Id;
|
||||
UserName = user.UserName;
|
||||
EMail = user.Email;
|
||||
Avatar = user.Avatar;
|
||||
PostalAddress = user.PostalAddress;
|
||||
DedicatedGoogleCalendar = user.DedicatedGoogleCalendar;
|
||||
Id = userId;
|
||||
UserName = userName;
|
||||
EMail = email;
|
||||
Avatar = avatar;
|
||||
PostalAddress = address;
|
||||
DedicatedGoogleCalendar = gCalId;
|
||||
}
|
||||
public string Id { get; set; }
|
||||
public string UserName { get; set; }
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
|
||||
namespace Yavsc.ViewModels.Administration
|
||||
{
|
||||
@ -9,11 +8,11 @@ namespace Yavsc.ViewModels.Administration
|
||||
{
|
||||
|
||||
}
|
||||
public RoleInfo ( IdentityRole role)
|
||||
public RoleInfo ( string roleName, string roleId, string[] users)
|
||||
{
|
||||
Name = role.Name;
|
||||
Id = role.Id;
|
||||
Users = role.Users.Select(u => u.UserId).ToArray();
|
||||
Name = roleName; // role.Name;
|
||||
Id = roleId; // role.Id;
|
||||
Users = users ; // role.Users.Select(u => u.UserId).ToArray();
|
||||
}
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
@ -1,11 +0,0 @@
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth
|
||||
{
|
||||
public class ViewFileContext
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public IFileInfo File { get; set; }
|
||||
public string Path { get; set; }
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Identity;
|
||||
|
||||
namespace Yavsc.ViewModels.Manage
|
||||
{
|
||||
using Models.Bank;
|
||||
using Models;
|
||||
using Models.Workflow;
|
||||
public class IndexViewModel
|
||||
{
|
||||
public string UserName {get; set; }
|
||||
|
||||
public string Avatar { get; set; }
|
||||
|
||||
public bool HasPassword { get; set; }
|
||||
|
||||
public IList<UserLoginInfo> Logins { get; set; }
|
||||
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
public bool TwoFactor { get; set; }
|
||||
|
||||
public bool BrowserRemembered { get; set; }
|
||||
|
||||
public List<UserActivity> Activity { get; set; }
|
||||
|
||||
public bool HaveProfessionalSettings { get; set; }
|
||||
public bool HaveActivityToConfigure { get; set; }
|
||||
|
||||
public long PostsCounter { get; set; }
|
||||
|
||||
public AccountBalance Balance { get; set; }
|
||||
|
||||
public long ActiveCommandCount { get; set; }
|
||||
|
||||
public bool HasDedicatedCalendar { get; set; }
|
||||
|
||||
public IEnumerable<string> Roles { get; set; }
|
||||
|
||||
public string FullName { get; set; }
|
||||
|
||||
public string PostalAddress { get; set; }
|
||||
|
||||
public BankIdentity BankInfo { get; set; }
|
||||
public long DiskQuota { get; set; }
|
||||
public long DiskUsage { get; set; }
|
||||
|
||||
public string DedicatedCalendarId { get; set; }
|
||||
|
||||
public string EMail { get; set; }
|
||||
public bool EmailConfirmed { get; set; }
|
||||
public bool AllowMonthlyEmail { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.Identity;
|
||||
|
||||
namespace Yavsc.ViewModels.Manage
|
||||
{
|
||||
public class ManageLoginsViewModel
|
||||
{
|
||||
public IList<UserLoginInfo> CurrentLogins { get; set; }
|
||||
|
||||
public IList<AuthenticationDescription> OtherLogins { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user