public async Task <ActionResult> AllBook([FromServices] QRContext context, string id) { var b = context.Book.FirstOrDefault(it => it.UniqueLink == id); if (b == null) { return(Content("no book")); } string pathFile = Path.Combine("epubs", $"{b.UniqueLink}_{b.Idbook.ToString("00#")}.epub"); if (!System.IO.File.Exists(pathFile)) { var pathFileFirst = Path.Combine("epubs", b.UniqueLink); if (System.IO.File.Exists(pathFileFirst)) { System.IO.File.Copy(pathFileFirst, pathFile); System.IO.File.Delete(pathFileFirst); } } if (!System.IO.File.Exists(pathFile)) { return(Content($"File for book {id} not exists")); } var read = new ReadEpubFile(pathFile); return(View(read)); }
public async Task <IActionResult> Index([FromServices] QRContext context) { if (!System.IO.File.Exists("data.sqlite3")) { try{ await Program.GetDatabase(); } catch (Exception ex) { return(Content(ex.Message)); } } var b = context.Book.Where(it => it.IsCorrect).ToArray(); return(View(b)); }
public async Task <ActionResult> GeneratedEmail([FromServices] QRContext context, string id) { var strSalt = Environment.GetEnvironmentVariable("deploy"); var hashids = new Hashids(strSalt); long idUser = hashids.DecodeLong(id)[0]; var user = context.SimpleUser.FirstOrDefault(it => it.Iduser == idUser); if (user == null) { return(Content("user does not exists")); } user.ConfirmedByEmail = true; await context.SaveChangesAsync(); await SignUser(user); return(RedirectToAction("index")); }
public SimpleUsersController(QRContext context) { _context = context; }
public CustomRepository(QRContext context) { this.db = context; }
public PhoneRepository() { db = new QRContext(); }
public PhoneRepository(QRContext context) { db = context; }
public BooksController(QRContext context) { _context = context; }
public QuestRoomRepository() { db = new QRContext(); }
public QuestRoomRepository(QRContext context) { db = context; }
public async Task <ActionResult> Register([FromServices] QRContext context, string emailUser, string password) { //TODO: make a better way to register users //TODO: use Google / Facebook authentication //TODO: email valid emailUser = emailUser?.ToLower(); var hash = getHash(password); if (hash.Length > 500) { hash = hash.Substring(0, 500); } var user = context.SimpleUser.FirstOrDefault(it => it.Email.ToLower() == emailUser); if (user != null) { if (!user.ConfirmedByEmail) { return(Content($"email {emailUser} does exists . Check your email")); } if (user.Password == hash) { await SignUser(user); return(RedirectToAction("Index")); } else { return(Content("incorrect password. Press back and try again")); } } user = new SimpleUser(); user.Email = emailUser; user.Name = emailUser; user.Password = hash; context.Add(user); await context.SaveChangesAsync(); var strSalt = Environment.GetEnvironmentVariable("deploy"); var hashids = new Hashids(strSalt); var id = hashids.EncodeLong(user.Iduser); string url = "http://fsq.apphb.com/Home/GeneratedEmail/" + id; var apiKey = Environment.GetEnvironmentVariable("SendGridKey"); var client = new SendGridClient(apiKey); var from = new EmailAddress("*****@*****.**", "Ignat Andrei - QR"); List <EmailAddress> tos = new List <EmailAddress> { new EmailAddress(emailUser), new EmailAddress("*****@*****.**"), new EmailAddress("*****@*****.**") }; var subject = "Confirmati inregistrarea la QR Code Library "; var htmlContent = $"Va rog <strong>confirmati </strong> inscrierea la QR Code library apasand <a href='{url}'>{url}</a>. <br />Multumim!"; var msg = MailHelper.CreateSingleEmailToMultipleRecipients(from, tos, subject, "", htmlContent, false); var response = await client.SendEmailAsync(msg); return(Content("Va rugam verificat emailul( inclusiv spam/ junk) pentru a confirma adresa de email !")); }