public ActionResult Report(ReportNoteModel Rm)
        {
            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/RegisteredUser/Downloads" }));
            }

            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
            }

            int UserID = Convert.ToInt32(User.Identity.Name);

            if (NotesRepository.SubmitNoteReport(Rm, UserID))
            {
                ViewBag.SellerName = Rm.SellerName;
                ViewBag.NoteName   = Rm.NoteTitle;
                ViewBag.BuyerName  = Session["FullName"];
                SendMail.SendEmail(new EmailModel()
                {
                    EmailTo      = SystemConfigData.GetSystemConfigData("AdminEmails").DataValue.Split(';'),
                    EmailSubject = Session["FullName"].ToString() + " reported an issue for " + Rm.NoteTitle,
                    EmailBody    = this.getHTMLViewAsString("~/Views/Email/ReportedNote.cshtml")
                });

                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK));
            }
            else
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.Forbidden));
            }
        }
Пример #2
0
 public static bool SendEmail(EmailModel email)
 {
     try
     {
         MailMessage mm = new MailMessage();
         mm.From = new MailAddress(SystemConfigData.GetSystemConfigData("MailAddress").DataValue, "Notes Marketplace");
         foreach (string address in email.EmailTo)
         {
             mm.To.Add(new MailAddress(address));
         }
         mm.Subject    = email.EmailSubject;
         mm.Body       = email.EmailBody;
         mm.IsBodyHtml = true;
         using (var smtp = new SmtpClient()
         {
             UseDefaultCredentials = false,
             Credentials = new NetworkCredential(mm.From.Address, SystemConfigData.GetSystemConfigData("MailPassword").DataValue)
         }
                )
         {
             smtp.Send(mm);
             return(true);
         }
     }catch (Exception e)
     {
         Debug.WriteLine(e);
         return(false);
     }
 }
Пример #3
0
        public ActionResult ContactUs(ContactUsModel cu)
        {
            if (Request.IsAuthenticated && Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            else if (Request.IsAuthenticated)
            {
                ViewBag.Authorized = true;
            }

            ViewBag.Title = "ContactUs";
            if (!ModelState.IsValid)
            {
                return(View(cu));
            }

            ViewBag.Name    = cu.FullName;
            ViewBag.Email   = cu.Email;
            ViewBag.Comment = cu.Comment;
            if (SendMail.SendEmail(new EmailModel()
            {
                EmailTo = SystemConfigData.GetSystemConfigData("AdminEmails").DataValue.Split(';'),
                EmailSubject = cu.Subject,
                EmailBody = this.getHTMLViewAsString("~/Views/Email/ContactUsMail.cshtml")
            }))
            {
                ViewBag.Message = "Thank you for contacting us, we will get back to you.";
                return(View(cu));
            }
            else
            {
                ViewBag.Message = "Something went wrong. Please try again.";
                return(View(cu));
            }
        }
        public ActionResult AddNotes(NoteModel Nm, string SaveOrPublish)
        {
            ViewBag.Title                = "AddNotes";
            ViewBag.Authorized           = true;
            ViewBag.LoadValidationScript = true;

            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication", new { ReturnUrl = "/RegisteredUser/AddNotes" }));
            }

            SearchNotesModel FilterData = new SearchNotesModel();

            FilterData.Type     = NotesFilters.Types();
            FilterData.Category = NotesFilters.Categories();
            FilterData.Country  = NotesFilters.Countries();
            ViewBag.FilterData  = FilterData;


            //check uploaded files and their size
            if (Nm.PreviewFile != null && (Path.GetExtension(Nm.PreviewFile.FileName).ToLower() != ".pdf" || Nm.PreviewFile.ContentLength > 31457280))
            {
                ModelState.AddModelError("PreviewFile", "Only PDF files that are under 30MBs are allowed.");
            }

            long NoteSize = 0;

            foreach (HttpPostedFileBase file in Nm.NotesFiles)
            {
                if (file == null)
                {
                    ModelState.AddModelError("NotesFiles", "Make sure you have uploaded PDF file(s) that are under 30MBs");
                }
                else if (Path.GetExtension(file.FileName).ToLower() != ".pdf")
                {
                    ModelState.AddModelError("NotesFiles", "Only PDF file(s) are allowed.");
                }
                if (file != null)
                {
                    NoteSize += file.ContentLength;
                }
            }
            if (NoteSize > 31457280)
            {
                ModelState.AddModelError("NotesFiles", "Combine PDF(s) size should not exceeds 30MBs");
            }


            if (Nm.NotesCoverPage != null && !MimeMapping.GetMimeMapping(Nm.NotesCoverPage.FileName).ToLower().Contains("image"))
            {
                ModelState.AddModelError("NotesCoverPage", "Only Images are allowed.");
            }

            if (!ModelState.IsValid)
            {
                return(View(Nm));
            }


            //0 for draft 1 for submit for review
            if (SaveOrPublish == "Save")
            {
                Nm.Status = 0;
            }
            else if (SaveOrPublish == "Publish")
            {
                Nm.Status = 1;
            }
            else
            {
                ViewBag.Message = "Adding / Editing note didnt go as expected please try again.";
                return(View(Nm));
            }

            ViewBag.Title                = "AddNotes";
            ViewBag.Authorized           = true;
            ViewBag.LoadValidationScript = true;
            string UID = User.Identity.Name;

            int result = NotesRepository.AddNote(Nm, Convert.ToInt32(UID), Server.MapPath("~"));

            if (result < 1)
            {
                ViewBag.Message = "Adding/Editing note didnt go as expected please try again.";
                return(View(Nm));
            }
            if (SaveOrPublish == "Publish")
            {
                ViewBag.SellerName = Session["FullName"];
                ViewBag.NoteName   = Nm.Title;
                SendMail.SendEmail(new EmailModel()
                {
                    EmailTo      = SystemConfigData.GetSystemConfigData("AdminEmails").DataValue.Split(';'),
                    EmailSubject = Session["FullName"].ToString() + " sent his note for review.",
                    EmailBody    = this.getHTMLViewAsString("~/Views/Email/RequestToReview.cshtml")
                });
                TempData["Message"] = "Note has been submitted for review, we will send you mail when it gets approved.";
            }
            else
            {
                TempData["Message"] = "Note has been successfully saved in Drafts";
            }

            return(RedirectToAction("Dashboard", "RegisteredUser"));
        }
Пример #5
0
        public ActionResult NoteDetails(string NoteId)
        {
            if (String.IsNullOrEmpty(NoteId))
            {
                return(new HttpNotFoundResult());
            }

            int UserID = 0;

            string[] UserRoles = null;

            if (Request.IsAuthenticated)
            {
                if (Session["UserID"] == null)
                {
                    return(RedirectToAction("Login", "Authentication"));
                }
                ViewBag.Authorized = true;

                UserID = Convert.ToInt32(User.Identity.Name);

                UserRoles = new RoleManager.NotesMarketPlaceRoleManager().GetRolesForUser(User.Identity.Name);
            }

            NoteModel Nm = NotesRepository.GetNoteDetailsById(Convert.ToInt32(NoteId));

            if (Nm == null)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound));
            }

            //Only show note details when notes is published or being accessed by owner or admins
            if (Nm.Status != 3 && (Request.IsAuthenticated && !(Nm.SellerID == UserID || UserRoles.Contains("SuperAdmin") || UserRoles.Contains("SubAdmin"))))
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound));
            }

            List <string> ReviewerList = new List <string>();

            foreach (Review r in Nm.Reviews)
            {
                ReviewerList.Add(r.ReviwerProfilePicture);
            }


            /* We will use this list in content controller to give anonymous users, access to those user profiles
             * which are included in notes reviews.
             */

            Session["ReviewerList"] = ReviewerList;

            //Adding Full Name of Seller and contact number of support for popup model

            SystemConfigModel SupportContact = SystemConfigData.GetSystemConfigData("SupportContact");

            if (SupportContact != null)
            {
                ViewBag.SupportContact = SupportContact.DataValue;
            }
            else
            {
                ViewBag.SupportContact = "Not Available";
            }

            //Full Name of Seller
            UserProfileModel Seller = UserRepository.GetUserData(Nm.SellerID);

            if (Seller != null)
            {
                ViewBag.Seller = Seller.User.FirstName + " " + Seller.User.LastName;
            }
            else
            {
                ViewBag.Seller = "Anonymous User";
            }

            //TempData passed by GetNoteAttachments method to confirm buyer request submission
            if (TempData.ContainsKey("BuyerRequestSubmitted") && (bool)TempData["BuyerRequestSubmitted"])
            {
                ViewBag.BuyerRequestSubmitted = true;
            }

            ViewBag.Title = "NotesDetails";
            return(View(Nm));
        }