public ActionResult BuyerRequests() { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/RegisteredUser/BuyerRequests" })); } int UID = Convert.ToInt32(User.Identity.Name); BuyerRequestsModel br = new BuyerRequestsModel(); DownloadsModel dm = DownloadRepository.GetDownloads(UID, 0); foreach (DownloadsModel.InnerClassDownload d in dm.DownloadProperty) { UserProfileModel usrp = UserRepository.GetUserData(d.Buyer.UserID); br.BRequests.Add(new BuyerRequestsModel.BuyerRequest() { BuyerEmail = d.Buyer.Email, BuyerPhone = usrp.PhoneNo != null ? usrp.CountryCode + " " + usrp.PhoneNo : "N/A", NoteTitle = d.NoteTitle, NoteID = d.NoteID, NoteCategory = d.NoteCategory, SellType = d.IsPaid ? "Paid" : "Free", DownloadID = d.DownloadID, ReqTime = (System.DateTime)d.RequestTime, Price = (int)d.PurchasedPrice }); } ViewBag.Authorized = true; ViewBag.Title = "BuyerRequests"; return(View(br)); }
public ActionResult AllowDownload(string id) { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/RegisteredUser/AllowDownload/" + id })); } int DownloadId = Convert.ToInt32(id); int UID = Convert.ToInt32(User.Identity.Name); int SuccessBuyerId = DownloadRepository.AllowDownload(DownloadId, UID); if (SuccessBuyerId <= 0) { return(new HttpStatusCodeResult(403)); } else { UserProfileModel usrp = UserRepository.GetUserData(SuccessBuyerId); ViewBag.BuyerName = usrp.User.FirstName + " " + usrp.User.LastName; ViewBag.SellerName = Session["FullName"].ToString(); SendMail.SendEmail(new EmailModel() { EmailTo = new string [] { usrp.User.Email }, EmailSubject = Session["FullName"].ToString() + "Allows you to download a note.", EmailBody = this.getHTMLViewAsString("~/Views/Email/AllowDownload.cshtml") }); return(RedirectToAction("BuyerRequests", "RegisteredUser")); } }
public ActionResult Dashboard() { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = "/RegisteredUser/Dashboard" })); } //Check if Admin string[] roles = new NotesMarketPlaceRoleManager().GetRolesForUser(User.Identity.Name); if (roles.Contains("SuperAdmin") || roles.Contains("SubAdmin")) { return(RedirectToAction("AdminDashBoard", "Admin")); } int UserID = Convert.ToInt32(User.Identity.Name); var Stats = DownloadRepository.GetUserStats(UserID); DashboardModel DM = new DashboardModel() { NotesSold = Stats.Item1, MoneyEarned = Stats.Item2, Downloads = Stats.Item3, Rejecteds = Stats.Item4, BuyerRequests = Stats.Item5, InProgressNotes = NotesRepository.GetInProgressNotes(UserID), PublishedNotes = NotesRepository.GetPublishedNotes(UserID) }; ViewBag.Title = "Dashboard"; ViewBag.Authorized = true; return(View(DM)); }
public IActionResult Index() { //veri cekme DownloadRepository dr = new DownloadRepository(); List <Download> list = dr.List(); return(View(list)); }
public DownloadRepositoryTest() { var c = new Mock <Context>(new DbContextOptionsBuilder().Options); Mock <Microsoft.Extensions.Configuration.IConfiguration> conf = MockConfig(); var dl = new Mock <DownloadRepository>(c.Object, conf.Object); this.downloadRepo = dl.Object; }
public HttpResponseMessage DirectDownload(int FileId) { try { DownloadRepository downloadRepo = new DownloadRepository(); HttpResponseMessage result = downloadRepo.DirectDownloadFromBase64(FileId); return(result); } catch (Exception ex) { return(this.Request.CreateResponse(HttpStatusCode.InternalServerError, ex)); } }
public ActionResult SoldNotes() { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/RegisteredUser/SoldNotes" })); } int UserID = Convert.ToInt32(User.Identity.Name); DownloadsModel soldNotes = DownloadRepository.GetDownloads(UserID, 2); // DownnloadStatus : 2 for sold notes ViewBag.Authorized = true; ViewBag.Title = "SoldNotes"; return(View(soldNotes)); }
public ActionResult Downloads() { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/RegisteredUser/Downloads" })); } int UserID = Convert.ToInt32(User.Identity.Name); DownloadsModel DownloadedNotes = DownloadRepository.GetDownloads(UserID, 1); // DownnloadStatus : 1 for downloads ViewBag.LoadAjaxJS = true; ViewBag.LoadValidationScript = true; ViewBag.Authorized = true; ViewBag.Title = "Downloads"; return(View(DownloadedNotes)); }
public ActionResult GetNotesAttachments(string NoteID) { if (Session["UserID"] == null) { return(Redirect("Authentication/Login?ReturnUrl=%2fAssets%2fNotes%2f" + NoteID)); } string [] NoteInfo = DownloadRepository.GetNoteAttachments(Convert.ToInt32(NoteID), Convert.ToInt32(User.Identity.Name)); string path = Server.MapPath("~/Members/"); if (NoteInfo == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } string NoteTitle = NoteInfo[0]; string AttachmentPath = NoteInfo[1]; //if buyer request is being submitted first time we send seller an email if (AttachmentPath.Contains("BuyerRequestSubmitted")) { string [] SellerInfo = AttachmentPath.Split(';'); string SellerEmail = SellerInfo[1]; //sending email ViewBag.SellerName = SellerInfo[2]; ViewBag.BuyerName = Session["FullName"]; SendMail.SendEmail(new EmailModel() { EmailTo = new string [] { SellerEmail }, EmailSubject = Session["FullName"] + " Wants to purchase your notes.", EmailBody = this.getHTMLViewAsString("~/Views/Email/BuyerRequest.cshtml") }); TempData["BuyerRequestSubmitted"] = true; return(RedirectToAction("NoteDetails/" + NoteID, "Home")); } else if (AttachmentPath == "BuyerRequestAlreadySubmitted") { TempData["BuyerRequestSubmitted"] = true; return(RedirectToAction("NoteDetails/" + NoteID, "Home")); } try { DirectoryInfo NoteDir = new DirectoryInfo(Path.Combine(path, AttachmentPath)); FileInfo[] Attachments = NoteDir.GetFiles(); MemoryStream ResponseFile = new MemoryStream(); if (Attachments.Count() == 1) { return(File(new FileStream(Attachments[0].FullName, FileMode.Open, FileAccess.Read), "application/pdf", NoteTitle + "-NotesMarketPlace.pdf")); } else if (Attachments.Count() > 1) { using (ZipFile zip = new ZipFile()) { zip.AddDirectory(Path.Combine(path, AttachmentPath)); zip.Save(ResponseFile); } ResponseFile.Position = 0; return(File(ResponseFile, "application/zip", NoteTitle + "-NotesMarketPlace.zip")); } else { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }catch (Exception e) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }