public ActionResult Index(SellNote model, SellerNotesAttachement mod, FormCollection fc, HttpPostedFileBase imgfile, HttpPostedFileBase pdffile)
        {
            var data = _context.NoteTypes.ToList();

            ViewBag.NoteType = new SelectList(data, "Name", "Name");
            var item = _context.Countries.ToList();

            ViewBag.Country = new SelectList(item, "Name", "Name");
            var item1 = _context.NoteCatgories.ToList();

            ViewBag.Category = new SelectList(item1, "Name", "Name");

            if (ModelState.IsValid)
            {
                var currenttime = DateTime.UtcNow;
                if (imgfile != null)
                {
                    model.Display_pic = new byte[imgfile.ContentLength];
                    imgfile.InputStream.Read(model.Display_pic, 0, imgfile.ContentLength);
                }
                if (pdffile != null)
                {
                    String FileExt = Path.GetExtension(pdffile.FileName).ToUpper();
                    if (FileExt == ".PDF")
                    {
                        Stream       str     = pdffile.InputStream;
                        BinaryReader Br      = new BinaryReader(str);
                        Byte[]       FileDet = Br.ReadBytes((Int32)str.Length);
                        mod.FileName       = model.FileName = pdffile.FileName;
                        mod.FileContent    = model.Upload_note = FileDet;
                        mod.AttachmentSize = pdffile.ContentLength / 1024;
                    }
                }
                if (fc["save"] == "SAVE")
                {
                    model.Status = "Draft";
                }
                if (fc["publish"] == "PUBLISH")
                {
                    model.Status = " Submitted for Review";
                }
                var res = _context.Registers.Where(x => x.EmailId == User.Identity.Name).Single().Id;
                model.Seller_Id  = res;
                mod.CreatedBy    = model.CreatedBy = User.Identity.Name;
                mod.CreatedDate  = model.CreatedDate = currenttime;
                mod.ModifiedBy   = model.ModifiedBy = User.Identity.Name;
                mod.ModifiedDate = model.ModifiedDate = currenttime;
                mod.NoteTitle    = model.title;
                _context.SellerNotesAttachements.Add(mod);
                _context.SellNotes.Add(model);
                _context.SaveChanges();
                return(RedirectToAction("ViewNotes"));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        public ActionResult ApproveNote(int id)
        {
            ViewBag.status = id;
            var result = _context.SellNotes.Where(x => x.Id == id).FirstOrDefault();

            if (result != null)
            {
                result.Status = "Published";
                _context.Entry(result).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
            }
            return(RedirectToAction("NoteUnderReview"));
        }
Ejemplo n.º 3
0
        public ActionResult Register(Register model)
        {
            if (ModelState.IsValid)
            {
                Guid Code = Guid.NewGuid();
                model.Code = "False";
                _context.Registers.Add(model);
                _context.SaveChanges();
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(model.EmailId);
                mail.Subject    = "confirmation Email";
                mail.IsBodyHtml = true;
                string content = "Hello, <br>" + model.FirstName + " " + model.LastName + " <br><br>";
                content += "Regards, <br>" + model.FirstName;

                Guid activationCode = Guid.NewGuid();

                string body = "Hello " + model.FirstName + ",";
                body += "<br /><br />Thank you for signing up with us. Please click on below link to verify your email address and to do login.";
                body += "<br /><a href = '" + string.Format("{0}://{1}/RegisterUser/Activation/{2}", Request.Url.Scheme, Request.Url.Authority, model.Id) + "'>Click here to activate your account.</a>";

                body     += "<br/><br/>Regards,<br/>NoteMarketPlace";
                mail.Body = body;
                SmtpClient        smtp = new SmtpClient("smtp.gmail.com");
                NetworkCredential nc   = new NetworkCredential("*****@*****.**", "nishu450");
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = nc;
                smtp.Port      = 587;
                smtp.EnableSsl = true;
                smtp.Send(mail);
                ViewBag.Message = "Mail Sent";
                return(View("Login"));
            }
            else
            {
                return(View());
            }
        }