Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Name,Message,AttachmentFile,Email")] ContactViewModel ContactViewModel1)
        {
            if (ModelState.IsValid)
            {
                Contact Contact1 = new Contact();
                Contact1.Name    = ContactViewModel1.Name;
                Contact1.Message = ContactViewModel1.Message;
                Contact1.Email   = ContactViewModel1.Email;

                PersianDateTime PersianDateTime1 = new PersianDateTime();
                Contact1.MessageDateTime = PersianDateTime1.GregorianToShamsi(DateTime.Now);

                if (ContactViewModel1.AttachmentFile != null)
                {
                    Contact1.AttachmentFileName = ContactViewModel1.AttachmentFile.FileName;
                    byte[] uploadFile = new byte[ContactViewModel1.AttachmentFile.InputStream.Length];
                    ContactViewModel1.AttachmentFile.InputStream.Read(uploadFile, 0, uploadFile.Length);
                    Contact1.AttachmentFile = uploadFile;
                    //byte[] uploadFile = new byte[file1.InputStream.Length];
                    //file1.InputStream.Read(uploadFile, 0, uploadFile.Length);
                    //Contact1.AttachmentFile = uploadFile;
                }

                db.Contacts.Add(Contact1);
                db.SaveChanges();
                return(RedirectToAction("Thanks"));
            }

            return(View(ContactViewModel1));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "Id,DateTime,Message,Timestamp")] Log log)
        {
            if (ModelState.IsValid)
            {
                db.Logs.Add(log);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(log));
        }
 public ActionResult Create([Bind(Include = "id,Name,Link,ReportedBy,Description")] ScammerViewModel ScammerViewModel)
 {
     if (ModelState.IsValid)
     {
         if (!db.Scammers.Any(r => r.Link == ScammerViewModel.Link))
         {
             Scammer scammer = new Scammer();
             scammer.Name        = ScammerViewModel.Name;
             scammer.Link        = ScammerViewModel.Link;
             scammer.Description = ScammerViewModel.Description;
             scammer.ReportedBy  = User.Identity.Name;
             db.Scammers.Add(scammer);
             db.SaveChanges();
             return(Json(new { success = true }));
         }
         else
         {
             ModelState.AddModelError("", "پروفایل شخص مورد نظر قبلا در لیست ثبت شده است.");
         }
     }
     return(PartialView("_Create", ScammerViewModel));
     //return Json(scammer, JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 4
0
        public void AddScammers()
        {
            DataContext.ErepDbContext erepDbContext = new ErepDbContext();
            //Erep.DomainClasses.Models.Scammer Scammer = new Scammer();

            foreach (List <string> listString in _scammersList)
            {
                Scammer scammer = new Scammer()
                {
                    Name = listString[0], Link = listString[1], ReportedBy = listString[2], Description = listString[3]
                };
                if (!erepDbContext.Scammers.Any(r => r.Link == scammer.Link))
                {
                    erepDbContext.Scammers.Add(scammer);
                    erepDbContext.SaveChanges();
                }
            }
        }