예제 #1
0
        // send mail to admin for publish note request
        public void PublishNot(string note, string seller)
        {
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "PublishNote" + ".cshtml");

            body = body.Replace("ViewBag.SellerName", seller);
            body = body.Replace("ViewBag.NoteTitle", note);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();
            var tomail    = _dbcontext.SystemConfigurations.Where(x => x.Key == "notifyemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = tomail.Value.Trim();
            subject = seller + " sent his note for review";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
예제 #2
0
        public IActionResult Post([FromForm] PokemonOrderModel order)
        {
            if (string.IsNullOrEmpty(order.Email))
            {
                ModelState.AddModelError(nameof(order.Email), "Please enter your email");
            }

            if (string.IsNullOrEmpty(order.Name))
            {
                ModelState.AddModelError(nameof(order.Email), "Please enter your name");
            }

            if (ModelState.IsValid)
            {
                var newItem = new PokemonOrder {
                    Email = order.Email, Name = order.Name, Phone = order.Phone, CreatedTime = DateTime.UtcNow
                };
                _repository.Insert(newItem);
                SendingEmail.Send(newItem);
                return(RedirectToAction(nameof(Feed)));
            }
            else
            {
                return(View("Index"));
            }
        }
예제 #3
0
        //get string from email template TemporaryPassword.cshtml
        public void BuildTemporaryPasswordTemplate(User user, string temporarypassword)
        {
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "TemporaryPassword" + ".cshtml");

            body = body.Replace("ViewBag.TemporaryPassword", temporarypassword);
            body = body.Replace("ViewBag.FirstName", user.FirstName);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = user.EmailID.Trim();
            subject = "New Temporary Password has been created for you";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
예제 #4
0
 /// <summary>
 /// Delete the user based on userid
 /// </summary>
 /// <param name="Id"></param>
 /// <returns></returns>
 public ActionResult Delete(string Id)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var user = context.AspNetUsers.Find(Id);
             context.AspNetUsers.Remove(user);
             context.SaveChanges();
             eventLog.SaveEventLog(ConstantEvent.UserDeleted, ConstantEvent.Successful);
             return(RedirectToAction("List"));
         }
         catch (Exception ex)
         {
             string mailSubjectForRegistration = "Deleting user Failure";
             string mailBodyForRegistration    = "";
             using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplate.html")))
             {
                 mailBodyForRegistration = reader.ReadToEnd();
             }
             mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDate]", DateTime.Now.ToString());
             mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDetail]", ex.StackTrace.ToString());
             mailBodyForRegistration = mailBodyForRegistration.Replace("[MessageDetail]", "the system tried to delete user from the MarketR System.");
             SendingEmail.SendMail(mailSubjectForRegistration, mailBodyForRegistration);
         }
     }
     return(View());
 }
예제 #5
0
        private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (Action == "AddMail")
            {
                SendingEmail wind = new SendingEmail();
                wind.ShowDialog();
            }

            if (Action == "AddFaktura")
            {
                AddEditFaktura wind = new AddEditFaktura();
                if (wind.ShowDialog().Value)
                {
                    MainWindow.instance.clear();
                    repozytorium.repozytorium.listFakturaSprzedazy.Add(wind.faktura);
                    MainWindow.instance.refresh( );
                }
            }

            if (Action == "AddFakturaZ")
            {
                AddEditFaktura wind = new AddEditFaktura();
                if (wind.ShowDialog().Value)
                {
                    MainWindow.instance.clear();
                    repozytorium.repozytorium.listFakturaZakupu.Add(wind.faktura);
                    MainWindow.instance.refresh();
                }
            }

            if (Action == "AddPracownik")
            {
                AddEditPracownik wind = new AddEditPracownik();
                if (wind.ShowDialog().Value)
                {
                    MainWindow.instance.clear();
                    repozytorium.repozytorium.listPracownikow.Add(wind.pracownik);
                    MainWindow.instance.refresh();
                }
            }

            if (Action == "AddNotatka")
            {
                MainWindow.instance.addNotatka();
            }

            if (Action == "AddWydarzenie")
            {
                AddWydarzenie temp = new AddWydarzenie();
                temp.ShowDialog();
            }
        }
예제 #6
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> Register(AccountRegistrationModel viewModel)
        {
            // Ensure we have a valid viewModel to work with
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }
            // Prepare the identity with the provided information
            var user = new IdentityUser
            {
                UserName = viewModel.Username ?? viewModel.Email,
                Email    = viewModel.Email
            };

            // Try to create a user with the given identity
            try
            {
                var result = await _manager.CreateAsync(user, viewModel.Password);

                // If the user could not be created
                if (!result.Succeeded)
                {
                    // Add all errors to the page so they can be used to display what went wrong
                    AddErrors(result);
                    return(View(viewModel));
                }

                // If the user was able to be created we can sign it in immediately
                // Note: Consider using the email verification proces
                await SignInAsync(user, false);

                return(RedirectToLocal());
            }
            catch (DbEntityValidationException ex)
            {
                // Add all errors to the page so they can be used to display what went wrong
                AddErrors(ex);
                string mailSubjectForRegistration = "User registration Failure";
                string mailBodyForRegistration    = "";
                using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplate.html")))
                {
                    mailBodyForRegistration = reader.ReadToEnd();
                }
                mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDate]", DateTime.Now.ToString());
                mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDetail]", ex.StackTrace.ToString());
                mailBodyForRegistration = mailBodyForRegistration.Replace("[MessageDetail]", "the system tried to register a user into the MarketR System.");
                SendingEmail.SendMail(mailSubjectForRegistration, mailBodyForRegistration);
                return(View(viewModel));
            }
        }
예제 #7
0
 public ActionResult SendEmail(Email emailModel)
 {
     if (ModelState.IsValid)
     {
         _emailService.AddEmail(emailModel);
         bool result = SendingEmail.SendEmail(emailModel);
         if (result)
         {
             ViewBag.Message = "Your message has been sent successfully!";
         }
         else
         {
             ViewBag.Message = "Error sending message :(";
         }
         return(View("SendEmail"));
     }
     return(View("Contact", emailModel));
 }
예제 #8
0
        public async Task <ActionResult> CreateUser(AccountRegistrationModel viewModel)
        {
            // Ensure we have a valid viewModel to work with
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            // Prepare the identity with the provided information
            var user = new IdentityUser
            {
                UserName = viewModel.Username ?? viewModel.Email,
                Email    = viewModel.Email
            };

            // Try to create a user with the given identity
            try
            {
                var result = await _manager.CreateAsync(user, viewModel.Password);

                // If the user could not be created
                if (!result.Succeeded)
                {
                    eventLog.SaveEventLog(ConstantEvent.NewUserCreated, ConstantEvent.Failed);
                    return(View(viewModel));
                }
                eventLog.SaveEventLog(ConstantEvent.NewUserCreated, ConstantEvent.Successful);
                return(RedirectToAction("List"));
            }
            catch (DbEntityValidationException ex)
            {
                string mailSubjectForRegistration = "Creating user Failure";
                string mailBodyForRegistration    = "";
                using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplate.html")))
                {
                    mailBodyForRegistration = reader.ReadToEnd();
                }
                mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDate]", DateTime.Now.ToString());
                mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDetail]", ex.StackTrace.ToString());
                mailBodyForRegistration = mailBodyForRegistration.Replace("[MessageDetail]", "the system tried to create user into the MarketR System.");
                SendingEmail.SendMail(mailSubjectForRegistration, mailBodyForRegistration);
                return(View(viewModel));
            }
        }
예제 #9
0
        // intializing the template that we want to send to admin for marking note as inappropriate
        private void SpamReportTemplate(SellerNotesReportedIssue spam, string membername)
        {
            string from, to, body, subject;

            // get all texts from SpamReport.cshtml from EmailTemplate
            body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "SpamReport" + ".cshtml");

            // get notes and user by using SellerNotesReportedIssue object
            var note   = _dbcontext.SellerNotes.Find(spam.NoteID);
            var seller = _dbcontext.Users.Find(note.SellerID);

            // replace some text with note title, seller name and user's name who mark this note as inappropriate
            body = body.Replace("ViewBag.SellerName", seller.FirstName + " " + seller.LastName);
            body = body.Replace("ViewBag.NoteTitle", note.Title);
            body = body.Replace("ViewBag.ReportedBy", membername);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();
            var tomail    = _dbcontext.SystemConfigurations.Where(x => x.Key == "notifyemail").FirstOrDefault();

            // set from, to, subject, body
            from    = fromemail.Value.Trim();
            to      = tomail.Value.Trim();
            subject = membername + " Reported an issue for " + note.Title;
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create object of MailMessage
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
예제 #10
0
        //get string from email template EmailVerification.cshtml
        public void BuildEmailVerifyTemplate(string baseurl, User user, string date)
        {
            // get text from email verification template
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "EmailVerification" + ".cshtml");

            // create url by user id and user registered date in string format
            var url = baseurl + "/Account/VerifyEmail?key=" + user.UserID + "&value=" + date;

            // replace url and first name
            body = body.Replace("ViewBag.ConfirmationLink", url);
            body = body.Replace("ViewBag.FirstName", user.FirstName);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = user.EmailID.Trim();
            subject = "Note Marketplace - Email Verification";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
예제 #11
0
        // for request to download we need to send mail to seller
        public void RequestPaidNotesTemplate(Downloads download, Users user)
        {
            // get all text from requestpaidnotes from emailtemplate directory
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "RequestPaidNotes" + ".cshtml");
            //get seller
            var seller = context.Users.Where(x => x.ID == download.Seller).FirstOrDefault();

            // replace seller name and buyer name from template
            body = body.Replace("ViewBag.SellerName", seller.FirstName);
            body = body.Replace("ViewBag.BuyerName", user.FirstName);
            body = body.ToString();

            // get support email
            var fromemail = context.SystemConfiguration.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = seller.EmailID.Trim();
            subject = user.FirstName + " wants to purchase your notes";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail)
            SendingEmail.SendEmail(mail);
        }
        public void AllowDownloadTemplate(Downloads download, Users seller)
        {
            // get text from allowdownload template from emailtemplate directory
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "SellerAllowDownloadTemplate" + ".cshtml");
            // get downloader user object
            var downloader = context.Users.Where(x => x.ID == download.Downloader).FirstOrDefault();

            // replace seller and buyer name
            body = body.Replace("ViewBag.SellerName", seller.FirstName);
            body = body.Replace("ViewBag.BuyerName", downloader.FirstName);
            body = body.ToString();

            // get support email
            var fromemail = context.SystemConfiguration.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = downloader.EmailID.Trim();
            subject = seller.FirstName + " Allows you to download a note";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
        public ActionResult AsyncUpload(IEnumerable <HttpPostedFileBase> files)
        {
            int count = 0;

            try
            {
                if (files != null)
                {
                    foreach (var file in files)
                    {
                        if (file != null && file.ContentLength > 0)
                        {
                            var fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                            var path     = Path.Combine(Server.MapPath("~/UploadedFiles"), fileName);
                            file.SaveAs(path);
                            count++;
                        }
                    }
                }
                return(new JsonResult {
                    Data = "Successfully " + count + " file(s) uploaded"
                });
            }
            catch (Exception ex)
            {
                string mailSubjectForRegistration = "Creating user Failure";
                string mailBodyForRegistration    = "";
                using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplate.html")))
                {
                    mailBodyForRegistration = reader.ReadToEnd();
                }
                mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDate]", DateTime.Now.ToString());
                mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDetail]", ex.StackTrace.ToString());
                mailBodyForRegistration = mailBodyForRegistration.Replace("[MessageDetail]", "the system tried to create user into the MarketR System.");
                SendingEmail.SendMail(mailSubjectForRegistration, mailBodyForRegistration);
                throw ex;
            }
        }
예제 #14
0
        /// <summary>
        /// Showing Nostro Deals
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public ActionResult NostroDeals()
        {
            List <FolderPermission> folderPermission = new List <FolderPermission>();

            try
            {
                if (Session["UserId"] != null)
                {
                    if (Session["UserRole"].ToString() == "Admin" || Session["UserRole"].ToString() == "Middle")
                    {
                        folderPermission = context.FolderPermissions.ToList();
                    }
                    else if (Session["UserRole"].ToString() == "DR")
                    {
                        folderPermission = context.FolderPermissions.Where(x => x.Folder == "Non Nostro").ToList();
                    }
                    else if (Session["UserRole"].ToString() == "Nostro")
                    {
                        folderPermission = context.FolderPermissions.Where(x => x.Folder == "Nostro").ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                string mailSubjectForRegistration = "Nostro/Non-Nostro deals loading Failure";
                string mailBodyForRegistration    = "";
                using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplate.html")))
                {
                    mailBodyForRegistration = reader.ReadToEnd();
                }
                mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDate]", DateTime.Now.ToString());
                mailBodyForRegistration = mailBodyForRegistration.Replace("[ErrorDetail]", ex.StackTrace.ToString());
                mailBodyForRegistration = mailBodyForRegistration.Replace("[MessageDetail]", "the system tried to load all the deals into the MarketR System.");
                SendingEmail.SendMail(mailSubjectForRegistration, mailBodyForRegistration);
            }
            return(View(folderPermission));
        }
예제 #15
0
        // send mail to admin
        public void BuildContactusTemplate(ContactUsViewModel contactusviewmodel)
        {
            string from, to, subject, bodytxt, body;

            // get all text from contactus from emailtemplate directory
            bodytxt = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "Contactus" + ".cshtml");
            // replace fullname and comment
            bodytxt = bodytxt.Replace("ViewBag.FullName", contactusviewmodel.FullName.Trim());
            bodytxt = bodytxt.Replace("ViewBag.Comment", contactusviewmodel.Comment.Trim());
            bodytxt = bodytxt.ToString();

            // get support email and notify email
            var fromemail = context.SystemConfiguration.Where(x => x.Key == "supportemail").FirstOrDefault();
            var tomail    = context.SystemConfiguration.Where(x => x.Key == "notifyemail").FirstOrDefault();

            // set from, to, subject, body
            from    = fromemail.Value.Trim();
            to      = tomail.Value.Trim();
            subject = contactusviewmodel.Subject + " - Query";
            StringBuilder sb = new StringBuilder();

            sb.Append(bodytxt);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
예제 #16
0
        public void UnpublishNoteTemplate(string remark, User seller)
        {
            // get text from unpublishnote template from emailtemplate directory
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "UnpublishNote" + ".cshtml");

            // replace seller and remark
            body = body.Replace("ViewBag.SellerName", seller.FirstName);
            body = body.Replace("ViewBag.Remark", remark);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = seller.EmailID.Trim();
            subject = "Sorry! We need to remove your notes from our portal.";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
예제 #17
0
        private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (Action == "AddMail")
            {
                SendingEmail wind = new SendingEmail();
                wind.ShowDialog();
            }

            if (Action == "AddFaktura")
            {
                var temp = MainWindow.instance.listFakturaSprzedazy.SelectedItem as Faktura;
                if (temp == null)
                {
                    MessageBox.Show("Brak zaznaczonej pozycji"); return;
                }
                AddEditFaktura wind = new AddEditFaktura(temp);
                if (wind.ShowDialog().Value)
                {
                    //////temp = wind.faktura;
                    ////MainWindow.instance.clear();
                    //repozytorium.repozytorium.listFakturaSprzedazy.Add(wind.faktura);
                    ///// MainWindow.instance.refresh();
                }
            }

            if (Action == "AddFakturaZ")
            {
                var temp = MainWindow.instance.listFakturaZakupu.SelectedItem as Faktura;
                if (temp == null)
                {
                    MessageBox.Show("Brak zaznaczonej pozycji"); return;
                }
                AddEditFaktura wind = new AddEditFaktura(temp);
                if (wind.ShowDialog().Value)
                {
                    // MainWindow.instance.clear();
                    /// repozytorium.repozytorium.listFakturaZakupu.Add(wind.faktura);
                    //// MainWindow.instance.refresh();
                }
            }

            if (Action == "AddPracownik")
            {
                var temp = MainWindow.instance.Pracownicy.SelectedItem as Pracownik;
                if (temp == null)
                {
                    MessageBox.Show("Brak zaznaczonej pozycji"); return;
                }
                AddEditPracownik wind = new AddEditPracownik(temp);
                if (wind.ShowDialog().Value)
                {
                    /// MainWindow.instance.clear();
                    /// repozytorium.repozytorium.listPracownikow.Add(wind.pracownik);
                    ///MainWindow.instance.refresh();
                }
            }

            if (Action == "AddNotatka")
            {
                // MainWindow.instance.addNotatka();
            }

            if (Action == "AddWydarzenie")
            {
                //var temp = MainWindow.instance.listFakturaZakupu.SelectedItem as Faktura;
                //if (temp == null) { MessageBox.Show("Brak zaznaczonej pozycji"); return; }
                //AddWydarzenie wind = new AddWydarzenie(temp);
                //if (wind.ShowDialog().Value)
                //{
                //    MainWindow.instance.clear();
                //    repozytorium.repozytorium.listFakturaZakupu.Add(wind.faktura);
                //    MainWindow.instance.refresh();
                //}
            }
        }