public async Task <ActionResult> Enroll(Customer customer) { if (!Request.IsAuthenticated) { if (!string.IsNullOrWhiteSpace(customer.Name)) { customer.Id = Guid.Parse(Request.QueryString["tid"].Trim()); var user = new User { Id = Guid.Parse(Request.QueryString["uid"].Trim()), FirstName = Request.QueryString["fn"].Trim(), }; customer.Users.Add(user); var context = new DashDocsContext(); context.Customers.Add(customer); await context.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } return(View()); } else { return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> Upload(HttpPostedFileBase document) { // Ids used in the seed method Guid customerId = Guid.Parse("82CEAD1F-E3FA-4DAB-BFFA-276845FB7E72"); Guid userId = Guid.Parse("2A37108E-56AF-4C18-99C4-415191591CD9"); var blobStorageService = new BlobStorageService(); var documentId = Guid.NewGuid(); var path = await blobStorageService. UploadDocumentAsync(document, customerId, documentId); var dbContext = new DashDocsContext(); dbContext.Documents.Add(new Document { Id = documentId, DocumentName = Path.GetFileName(document.FileName). ToLower(), OwnerId = userId, CreatedOn = DateTime.UtcNow, BlobPath = path }); await dbContext.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Upload(HttpPostedFileBase document) { var blobStorageService = new BlobStorageService(); var documentId = Guid.NewGuid(); var path = await blobStorageService.UploadDocumentAsync(document, DashDocsClaims.CustomerId, documentId); var dbContext = new DashDocsContext(); var documentModel = new Document { Id = documentId, DocumentName = Path.GetFileName(document.FileName).ToLower(), OwnerId = DashDocsClaims.UserId, CreatedOn = DateTime.UtcNow, BlobPath = path }; dbContext.Documents.Add(documentModel); await dbContext.SaveChangesAsync(); var doc = new DocumentViewModel { DocumentId = documentModel.Id, Owner = DashDocsClaims.DisplayName, CreatedOn = documentModel.CreatedOn, DocumentName = documentModel.DocumentName, }; var redisService = new RedisService(); await redisService.UpdateDocumentCacheAsync(DashDocsClaims.CustomerId, doc); return(RedirectToAction("Index")); }
public async Task <FileResult> Download(Guid documentId) { var dbContext = new DashDocsContext(); var document = await dbContext.Documents.SingleAsync(d => d.Id == documentId); var blobStorageService = new BlobStorageService(); var content = await blobStorageService.DownloadDocumentAsync(documentId, DashDocsClaims.CustomerId); return(File(content.Value, System.Net.Mime.MediaTypeNames.Application.Octet, content.Key)); }
public Task AuthCodeReceived(AuthorizationCodeReceivedNotification notification) { var oid = Guid.Parse(notification.JwtSecurityToken.Claims.Single(c => c.Type == "oid").Value); var tid = Guid.Parse(notification.JwtSecurityToken.Claims.Single(c => c.Type == "tid").Value); var firstname = notification.JwtSecurityToken.Claims.Single(c => c.Type == "name").Value; var context = new DashDocsContext(); var customer = context.Customers.SingleOrDefault(c => c.Id == tid); if (customer != null) { var user = context.Users.SingleOrDefault(u => u.Id == oid && u.CustomerId == tid); if (user == null) { // new user first sign-in user = new User { Id = oid, CustomerId = tid, FirstName = firstname }; context.Users.Add(user); context.SaveChanges(); } // though the application can access the claims from the returned // JWTToken, it's better to have custom claim properties as this eases up the usage. var applicationClaims = new AppClaims { CustomerId = tid, CustomerName = customer.Name, UserId = oid, DisplayName = user.FirstName + user.LastName }; var claim = new Claim("ddcs", JsonConvert.SerializeObject(applicationClaims)); notification.AuthenticationTicket.Identity.AddClaim(claim); var tableStorageService = new TableStorageService(); tableStorageService.CreateLog(tid, oid, notification.Request.RemoteIpAddress, true, null); } else { throw new UserLoggedInWithoutExistingCustomerException() { TenantId = tid, UserId = oid, FirstName = firstname }; } return(Task.FromResult(0)); }
public async Task<ActionResult> Index() { Guid customerId = Guid.Parse("48CC71AE-22E9-4CA3-96AD-5D53D38215AE"); var dbContext = new DashDocsContext(); var documents = from document in dbContext.Documents join user in dbContext.Users on document.OwnerId equals user.Id where user.CustomerId == customerId select document; return View(documents.Include(d => d.Owner).ToList()); }
public async Task<FileResult> Download(Guid documentId) { var dbContext = new DashDocsContext(); var document = await dbContext.Documents.SingleAsync(d => d.Id == documentId); var blobStorageService = new BlobStorageService(); var content = await blobStorageService.DownloadDocumentAsync(documentId, Guid.Parse("48CC71AE-22E9-4CA3-96AD-5D53D38215AE")); content.Value.Position = 0; return File(content.Value, System.Net.Mime.MediaTypeNames. Application.Octet, content.Key); }
public async Task <FileResult> Download(Guid documentId) { Guid customerId = Guid.Parse("82CEAD1F-E3FA-4DAB-BFFA-276845FB7E72"); var dbContext = new DashDocsContext(); var document = await dbContext.Documents.SingleAsync(d => d.Id == documentId); var blobStorageService = new BlobStorageService(); var content = await blobStorageService.DownloadDocumentAsync(documentId, customerId); return(File(content.Item1, System.Net.Mime.MediaTypeNames.Application.Octet, content.Item2)); }
public async Task <ActionResult> Index() { Guid customerId = Guid.Parse("82CEAD1F-E3FA-4DAB-BFFA-276845FB7E72"); var dbContext = new DashDocsContext(); var documents = from document in dbContext.Documents join user in dbContext.Users on document.OwnerId equals user.Id where user.CustomerId == customerId select document; return(View(documents.Include(d => d.Owner).ToList())); }
public ActionResult Index() { var customerId = DashDocsClaims.CustomerId; var dbContext = new DashDocsContext(); var documents = from document in dbContext.Documents join user in dbContext.Users on document.OwnerId equals user.Id where user.CustomerId == DashDocsClaims.CustomerId orderby document.CreatedOn descending select document; return(View(documents.Include(d => d.Owner).Take(10).ToList())); }
public ActionResult Index() { Guid customerId = Guid.Parse("82CEAD1F-E3FA-4DAB-BFFA-276845FB7E72"); var dbContext = new DashDocsContext(); var documents = from document in dbContext.Documents join user in dbContext.Users on document.OwnerId equals user.Id where user.CustomerId == customerId orderby document.CreatedOn descending select document; return(View(documents.Include(d => d.Owner).Take(10).ToList())); }
public async Task <ActionResult> Index() { Guid documentId = Guid.Empty; if (Request.QueryString["documentId"] != null && Guid.TryParse(Request.QueryString["documentId"], out documentId)) { var dbContext = new DashDocsContext(); var document = dbContext.Documents.Single(d => d.Id == documentId); var docucmentDbContext = new DocumentDbService(); var comments = await docucmentDbContext.GetCommentsAsync(documentId, DashDocsClaims.CustomerId); var result = new KeyValuePair <Document, List <Comment> >(document, comments); return(View(result)); } else { return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> Upload(HttpPostedFileBase document) { var blobStorageService = new BlobStorageService(); var documentId = Guid.NewGuid(); var path = await blobStorageService.UploadDocument(document, DashDocsClaims.CustomerId, documentId); var dbContext = new DashDocsContext(); dbContext.Documents.Add(new Document { Id = documentId, DocumentName = Path.GetFileName(document.FileName).ToLower(), OwnerId = DashDocsClaims.UserId, CreatedOn = DateTime.UtcNow, BlobPath = path }); await dbContext.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task<ActionResult> Upload(HttpPostedFileBase document) { // Ids used in the seed method Guid customerId = Guid.Parse("48CC71AE-22E9-4CA3-96AD-5D53D38215AE"); Guid userId = Guid.Parse("AD3C9066-A800-41A8-9C8D-A06ABB72AE2B"); var blobStorageService = new BlobStorageService(); var documentId = Guid.NewGuid(); var path = await blobStorageService. UploadDocumentAsync(document, customerId, documentId); var dbContext = new DashDocsContext(); dbContext.Documents.Add(new Document { Id = documentId, DocumentName = Path.GetFileName(document.FileName). ToLower(), OwnerId = userId, CreatedOn = DateTime.UtcNow, BlobPath = path }); await dbContext.SaveChangesAsync(); return RedirectToAction("Index"); }