public AphorismsController(
     ILogger <AphorismsController> logger,
     IAphorismsService aphorismsService,
     IMapper mapper)
 {
     _logger           = logger;
     _aphorismsService = aphorismsService;
     _mapper           = mapper;
 }
示例#2
0
 public ManageAphorismsModel(
     UserManager <ApplicationUser> userManager,
     RoleManager <IdentityRole> roleManager,
     IAphorismsService aphorismsService)
 {
     _userManager      = userManager;
     this.roleManager  = roleManager;
     _aphorismsService = aphorismsService;
 }
示例#3
0
 public EditAphorismModel(
     UserManager <ApplicationUser> userManager,
     IAphorismsService aphorismsService,
     IConfiguration configuration,
     IEmailSender emailSender,
     IOptions <EmailSenderOptions> emailSenderOptions)
 {
     _userManager        = userManager;
     _aphorismsService   = aphorismsService;
     _configuration      = configuration;
     _emailSender        = emailSender;
     _emailSenderOptions = emailSenderOptions.Value;
 }
        public static async Task SeedAphorismsAsync(
            ILogger logger,
            ApplicationDbContext context,
            IAphorismsService aphorismsService,
            string path, string culture = "it-IT")
        {
            try
            {
                if (context.Aphorisms.Any())
                {
                    return;
                }

                // This text is added only once to the file.
                if (File.Exists(path))
                {
                    // Open the file to read from.
                    string[] readText = File.ReadAllLines(path);
                    foreach (string s in readText)
                    {
                        if (string.IsNullOrEmpty(s))
                        {
                            continue;
                        }

                        if (!s.Contains("{0}"))
                        {
                            continue;
                        }

                        await aphorismsService.AddAphorism(s, culture, null, false);
                    }

                    await context.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
            }
        }
 public IndexModel(ILogger <IndexModel> logger, IAphorismsService aphorismsService)
 {
     _logger           = logger;
     _aphorismsService = aphorismsService;
 }
 public ManagePendingAphorismsModel(IAphorismsService aphorismsService)
 {
     _aphorismsService = aphorismsService;
 }