public ActionResult Buyer_Allowed(int id) { NotesMarketPlaceEntities a = new NotesMarketPlaceEntities(); var obj = a.tblDownloads.Where(m => m.ID.Equals(id)).FirstOrDefault(); int buyer_id = obj.Downloader; int seller_id = obj.Seller; var buyer = a.tblUsers.Where(m => m.ID.Equals(buyer_id)).FirstOrDefault(); var seller = a.tblUsers.Where(m => m.ID.Equals(seller_id)).FirstOrDefault(); if (obj != null) { // int id = admin_id.ID; obj.IsSellerHasAllowedDownload = true; string buyer_email = buyer.EmailID; string buyer_name = buyer.FirstName; buyer_name += " " + buyer.LastName; string seller_name = seller.FirstName; seller_name += " " + seller.LastName; string subject = seller_name + " Allows you to download a note"; ForgotPass mailer = new ForgotPass(); string body = "Hello " + buyer_name + ",<br/><br/>We would like to inform you that," + seller_name + " Allows you to download a note." + "Please login and see My Download tabs to download particular note." + "<br/><br/>Regards,<br/>Notes Marketplace"; mailer.sendMail(subject, body, buyer_email); a.SaveChanges(); } return(RedirectToAction("Buyer_requests", "Client")); }
public ActionResult Paid_download(int id) { var user_email = dbobject.tblUsers.Where(m => m.EmailID.Equals(User.Identity.Name)).FirstOrDefault(); var tblSeller = dbobject.tblSellerNotes.Where(m => m.ID == id).FirstOrDefault(); var user_id = user_email.ID; var checkdownload = dbobject.tblDownloads.Where(m => m.NoteID == id && m.Downloader == user_id).FirstOrDefault(); if (checkdownload != null) { return(Json(new { success = true, alertMsg = "already downloaded this note." }, JsonRequestBehavior.AllowGet)); } //tblSellerNote tblSeller = dbobj.tblSellerNotes.Find(id).; if (tblSeller == null || tblSeller.Status != 9) { return(HttpNotFound()); } else if (tblSeller != null && tblSeller.Status == 9) { var seller = dbobject.tblUsers.Where(m => m.ID == tblSeller.SellerID).FirstOrDefault(); string path = (from sa in dbobject.tblSellerNotesAttachements where sa.NoteID == tblSeller.ID select sa.FilePath).First().ToString(); string category = (from c in dbobject.tblNoteCategories where c.ID == tblSeller.Category select c.Name).First().ToString(); string seller_name = seller.FirstName; seller_name += " " + seller.LastName; string buyer_name = user_email.FirstName; buyer_name += " " + user_email.LastName; string buyer_email = seller.EmailID; tblDownload obj = new tblDownload(); obj.NoteID = tblSeller.ID; obj.Seller = tblSeller.SellerID; obj.Downloader = user_id; obj.IsSellerHasAllowedDownload = false; obj.AttachmentPath = path; obj.IsAttachmentDownloaded = false; obj.IsPaid = true; obj.PurchasedPrice = tblSeller.SellingPrice; obj.NoteTitle = tblSeller.Title; obj.NoteCategory = category; obj.CreatedDate = DateTime.Now; dbobject.tblDownloads.Add(obj); string subject = buyer_name + " wants to purchase your notes"; string body = "Hello" + " " + seller_name + ",<br/><br/>We would like to inform you that, " + buyer_name + " wants to purchase your notes." + " Please see Buyer Requests tab and allow download access to Buyer if you have received " + "the payment from him.<br/><br/>Regards,<br/>Notes Marketplace"; ForgotPass mailer = new ForgotPass(); mailer.sendMail(subject, body, buyer_email); dbobject.SaveChanges(); ViewBag.Msg = "Request Added"; return(Json(new { success = true, responseText = seller_name }, JsonRequestBehavior.AllowGet)); //#codebyChandreshMendapara } return(Json(new { success = false, responseText = "Error..." }, JsonRequestBehavior.AllowGet)); }