コード例 #1
0
        public void AllowDownloadTemplate(Downloads download, NotesMarketPlace.Context.Users seller)
        {
            var downloader = dobj.Users.Where(x => x.ID == download.Downloader).FirstOrDefault();

            var    email             = dobj.SystemConfiguration.Select(x => x.EmailID1).FirstOrDefault();
            var    fromEmail         = new MailAddress(email);
            var    toEmail           = new MailAddress(downloader.EmailID);
            var    fromEmailPassword = "******"; // Replace with original password
            string subject           = seller.FirstName + "Allows you to download a note";

            string body = "Hello " + downloader.FirstName + "," +
                          "<br/><br/>We would like to inform you that," + seller.FirstName + " Allows you to download a note " +
                          "<br/> Please login and see My Download tabs to download particular note." +
                          "<br/><br/>Regards,<br/>Notes Marketplace";

            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromEmail.Address, fromEmailPassword)
            };

            using (var message = new MailMessage(fromEmail, toEmail)
            {
                Subject = subject,
                Body = body,
                IsBodyHtml = true
            })
                smtp.Send(message);
        }
コード例 #2
0
        public ActionResult AllowDownload(int id)
        {
            NotesMarketPlace.Context.Users user = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();

            Downloads download = dobj.Downloads.Find(id);

            if (user.ID == download.Seller)
            {
                NotesAttachments attachement = dobj.NotesAttachments.Where(x => x.NoteID == download.NoteID && x.IsActive == true).FirstOrDefault();


                dobj.Downloads.Attach(download);
                download.IsSellerHasAllowedDownload = true;
                download.AttachmentPath             = attachement.FilePath;
                download.ModifiedBy   = user.ID;
                download.ModifiedDate = DateTime.Now;
                dobj.SaveChanges();

                AllowDownloadTemplate(download, user);

                return(RedirectToAction("BuyerRequest"));
            }
            else
            {
                return(RedirectToAction("BuyerRequest"));
            }
        }
コード例 #3
0
        public void Mailforpaid(Downloads download, NotesMarketPlace.Context.Users user)
        {
            var downloader = dobj.Users.Where(x => x.ID == download.Downloader).FirstOrDefault();
            var seller     = dobj.Users.Where(x => x.ID == download.Seller).FirstOrDefault();

            var    fromEmail         = new MailAddress(dobj.SystemConfiguration.FirstOrDefault().EmailID1);
            var    toEmail           = new MailAddress(seller.EmailID);
            var    fromEmailPassword = "******"; // Replace with actual password
            string subject           = seller.FirstName + "wants to purchase your notes";

            string body = "Hello" + seller.FirstName + "," +
                          "<br/><br/>We would like to inform you that," + downloader.FirstName + "wants to purchase your notes.Please see" +
                          "<br/>Buyer Requests tab and allow download access to Buyer if you have received the payment from" +
                          "<br/>him." +
                          "<br/><br/>Regards,<br/>Notes Marketplace";

            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromEmail.Address, fromEmailPassword)
            };

            using (var message = new MailMessage(fromEmail, toEmail)
            {
                Subject = subject,
                Body = body,
                IsBodyHtml = true
            })
                smtp.Send(message);
        }
コード例 #4
0
        public ActionResult BuyerRequest(string search, string sort, int?page)
        {
            ViewBag.BuyerRequest = "active";
            ViewBag.Sort         = sort;
            ViewBag.Search       = search;
            ViewBag.PageNumber   = page;

            NotesMarketPlace.Context.Users user = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();


            IEnumerable <BuyerRequest> buyerrequest = from download in dobj.Downloads
                                                      join users in dobj.Users on download.Downloader equals users.ID
                                                      join userprofile in dobj.UserProfileDetail on download.Downloader equals userprofile.UserID
                                                      where download.Seller == user.ID && download.IsSellerHasAllowedDownload == false && download.AttachmentPath == null
                                                      select new BuyerRequest
            {
                NoteID         = download.NoteID,
                DownloadID     = download.ID,
                Title          = download.NoteTitle,
                Category       = download.NoteCategory,
                Buyer          = users.EmailID,
                PhoneNo        = userprofile.CountryCode + " " + userprofile.PhoneNumber,
                SellType       = download.IsPaid == true ? "Paid" : "Free",
                SellingPrice   = download.PurchasedPrice,
                DownloadedDate = download.CreatedDate.Value
            };


            if (!string.IsNullOrEmpty(search))
            {
                search       = search.ToLower();
                buyerrequest = buyerrequest.Where(
                    x => x.Title.ToLower().Contains(search) ||
                    x.Category.ToLower().Contains(search) ||
                    x.Buyer.ToLower().Contains(search) ||
                    x.SellingPrice.ToString().ToLower().Contains(search) ||
                    x.PhoneNo.ToLower().Contains(search) ||
                    x.SellType.ToLower().Contains(search)
                    );
            }


            buyerrequest = SortTableBuyerRequest(sort, buyerrequest);

            var buyer = new List <BuyerRequest>();

            buyer = buyerrequest.ToList();

            return(View(buyer.ToList().AsQueryable().ToPagedList(page ?? 1, 10)));
        }
コード例 #5
0
        public ActionResult ManageSystemConfigurations()
        {
            var emailid = User.Identity.Name.ToString();

            NotesMarketPlace.Context.Users admin = dobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            SystemConfiguration sct = dobj.SystemConfiguration.FirstOrDefault();

            SystemConfigurationModel model = new SystemConfigurationModel();

            model.EmailID1 = sct.EmailID1;

            model.PhoneNumber = sct.PhoneNumber;
            model.EmailID2    = sct.EmailID2;
            model.FacebookURL = sct.FacebookUrl;
            model.TwitterURL  = sct.TwitterUrl;
            model.LinkedInURL = sct.LinkedInUrl;

            ViewBag.ProfilePicture = dobj.AdminDetail.Where(x => x.AdminID == admin.ID).Select(x => x.ProfilePicture).FirstOrDefault();
            return(View(model));
        }
コード例 #6
0
        public ActionResult AddAdministrator(AddAdministrator obj)
        {
            if (ModelState.IsValid)
            {
                // check if EmailID already exists or not
                bool EmailIDalreadyexists = dobj.Users.Where(x => x.EmailID == obj.Email).Any();
                if (EmailIDalreadyexists)
                {
                    ModelState.AddModelError("EmailID", "EmailID already exists");
                    obj.CountryCodeList = dobj.Countries.Where(x => x.IsActive).OrderBy(x => x.CountryCode).Select(x => x.CountryCode).ToList();
                    return(View(obj));
                }

                // get logged in superadmin
                var superadmin = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();

                //create object of user
                //set default password for admin is Admin@123
                //admin can change password after login through change password page
                NotesMarketPlace.Context.Users user = new NotesMarketPlace.Context.Users
                {
                    FirstName       = obj.FirstName.Trim(),
                    LastName        = obj.LastName.Trim(),
                    RoleID          = 2,
                    EmailID         = obj.Email.Trim(),
                    Password        = "******",
                    IsEmailVerified = true,
                    CreatedDate     = DateTime.Now,
                    CreatedBy       = superadmin.ID,
                    IsActive        = true
                };

                dobj.Users.Add(user);
                dobj.SaveChanges();

                // get saved admin id
                var addedadmin = dobj.Users.Find(user.ID);

                // crate userprofile object
                AdminDetail userProfile = new AdminDetail
                {
                    AdminID     = addedadmin.ID,
                    CountryCode = obj.CountryCode.Trim(),
                    PhoneNumber = obj.PhoneNumber.Trim(),

                    CreatedDate = DateTime.Now,
                    CreatedBy   = superadmin.ID
                };

                // save object in admindetail database
                dobj.AdminDetail.Add(userProfile);
                dobj.SaveChanges();

                return(RedirectToAction("ManageAdministrator"));
            }
            else
            {
                obj.CountryCodeList = dobj.Countries.Where(x => x.IsActive).OrderBy(x => x.CountryCode).Select(x => x.CountryCode).ToList();
                return(View(obj));
            }
        }