public ActionResult Create(string Comment)
        {
            if (Comment == "")
            {
                ViewData["Error"] = "Please write something";
                return(RedirectToAction("index", new { id = Session["pid"] }));
            }

            if (Session["id"] != null)
            {
                u = db.Users_Tbl.Find(Session["id"]);
                p = db.Posts_Tbl.Find(Session["pid"]);
                if (u != null && p != null && u.Status == "Approved")
                {
                    c.PostId = p.PostId;
                    c.UserId = u.UserId;
                    c.Date   = Convert.ToString(DateTime.Now);
                    c.Name   = Comment;

                    db.Comment_Tbl.Add(c);
                    db.SaveChanges();
                    ViewData["Error"] = "Successfully Added";
                    return(View("Index", db.Comment_Tbl.Where(x => x.PostId == p.PostId)));
                }
                return(RedirectToAction("index", "Posts_Tbl"));
            }
            return(RedirectToAction("index", "Posts_Tbl"));
        }
Example #2
0
 public static UserDetailsDTO GetStatusNamesForUser(Users_Tbl user)
 {
     using (BeitHamoreProjectEntities db = new BeitHamoreProjectEntities())
     {
         if (user != null)
         {
             var tt = new UserDetailsDTO
             {
                 tz             = user.tz,
                 userId         = user.userId,
                 city           = user.city,
                 emailAddress   = user.emailAddress,
                 firstName      = user.firstName,
                 houseNumber    = user.houseNumber,
                 lastName       = user.lastName,
                 phone          = user.phone,
                 passwordSHA256 = user.passwordSHA256,
                 street         = user.street,
                 StatusList     = db.StatusesToUsers_Tbl.Include(st => st.Status_Tbl).Where(st => st.userId ==
                                                                                            user.userId && st.isApproved.Value == 1).ToList().Select(sp => StatusDTOConverssions.GetStatus(sp.Status_Tbl)).ToList()
             };
             return(tt);
         }
         return(null);
     }
 }
 public ActionResult Edit([Bind(Include = "UserId,RollId,Name,Status,Username,Email,Number,CNIC,Password,SignUpDate,ApprovalDate")] Users_Tbl users_Tbl)
 {
     if (users_Tbl.Password == null || users_Tbl.Number == null || users_Tbl.Name == null)
     {
         ViewData["ED"] = "Please fill all the fields";
         return(View(users_Tbl));
     }
     if (users_Tbl.Password.Count() > 12 || users_Tbl.Password.Count() < 8)
     {
         ViewData["ED"] = "Password length should be minimum 8 characters and maximum 12 characters";
         return(View(users_Tbl));
     }
     if (users_Tbl.Number.Count() > 11 || users_Tbl.Number.Count() < 11)
     {
         ViewData["ED"] = "Phone number should be of 11 characters and the format should be 03xxxxxxxxx";
         return(View(users_Tbl));
     }
     if (ModelState.IsValid)
     {
         db.Entry(users_Tbl).State = EntityState.Modified;
         db.SaveChanges();
         ViewData["Error"] = "Successfully edited";
         return(View("Index", db.Users_Tbl.Where(x => x.Status == "Approved").ToList().ToPagedList(1, 10)));
     }
     return(View(users_Tbl));
 }
 // GET: Posts_Tbl/Edit/5
 public ActionResult Edit(int?id)
 {
     ViewData["Error"] = "";
     Session["pdiv"]   = id;
     if (Session["id"] != null)
     {
         u = db.Users_Tbl.Find(Session["id"]);
         p = db.Posts_Tbl.Find(id);
         if (u.RollId == 1 || (p.UserId == u.UserId && p.Status == "Pending"))
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             Posts_Tbl posts_Tbl = db.Posts_Tbl.Find(id);
             if (posts_Tbl == null)
             {
                 return(HttpNotFound());
             }
             return(View(posts_Tbl));
         }
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult login(Users_Tbl us)
 {
     u = db.Users_Tbl.FirstOrDefault(x => x.Username == us.Username && x.Password == us.Password);
     if (u != null)
     {
         Session["id"] = u.UserId;
         return(RedirectToAction("Index", "Home"));
     }
     ViewData["login"] = "******";
     return(View("login"));
 }
 public ActionResult chalan(/*int ? page*/)
 {
     if (Session["id"] != null)
     {
         u = db.Users_Tbl.Find(Session["id"]);
         if (u.RollId == 1)
         {
             ViewData["Error"] = "Successfully Approved";
             return(View(db.Users_Tbl.Where(x => x.Status == "pending" && (x.AreaId == u.AreaId || u.DesignationId == 1)).OrderByDescending(x => x.UserId).ToList() /*.ToPagedList(page ?? 1,10)*/));
         }
     }
     return(RedirectToAction("Index"));
 }
Example #7
0
 // GET: Contactus_Tbl
 public ActionResult Index()
 {
     ViewData["ED"] = "";
     if (Session["id"] != null)
     {
         u = db.Users_Tbl.Find(Session["id"]);
         if (u.RollId == 1)
         {
             return(View(db.Contactus_Tbl.OrderByDescending(x => x.ContactId).ToList()));
         }
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult chalan(int?page)
 {
     ViewData["Error"] = "Successfully approved";
     if (Session["id"] != null)
     {
         u = db.Users_Tbl.Find(Session["id"]);
         if (u.RollId == 1)
         {
             return(View(db.Posts_Tbl.OrderByDescending(x => x.PostId).Where(x => x.Status == "pending" && (x.AreaId == u.AreaId || u.DesignationId == 1)).ToList().ToPagedList(page ?? 1, 10)));
         }
         return(Redirect("index"));
     }
     return(Redirect("index"));
 }
        // GET: Users_Tbl/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Users_Tbl users_Tbl = db.Users_Tbl.Find(id);

            if (users_Tbl == null)
            {
                return(HttpNotFound());
            }
            return(View(users_Tbl));
        }
 // GET: Posts_Tbl/Create
 public ActionResult Create()
 {
     if (Session["id"] != null)
     {
         u = db.Users_Tbl.Find(Convert.ToInt32(Session["id"]));
         if (u.Status == "Approved")
         {
             ViewBag.categoryid = new SelectList(db.Category_Tbl, "categoryid", "Name");
             ViewBag.areaid     = new SelectList(db.Area_Tbl, "Areaid", "AreaName");
             return(View());
         }
         return(RedirectToAction("Index ", "Home"));
     }
     return(RedirectToAction("Index ", "Home"));
 }
        // GET: Users_Tbl
        public ActionResult Index(string Search, int?page)

        {
            if (Session["id"] != null)
            {
                u = db.Users_Tbl.Find(Session["id"]);
                if (u.RollId == 1)
                {
                    ViewData["Error"] = "";
                    return(View(db.Users_Tbl.Where(x => ((x.Name.Contains(Search) && x.Status == "Approved") || (Search == null && x.Status == "Approved"))).ToList().ToPagedList(page ?? 1, 10)));
                }
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #12
0
 public static bool Register(Users_Tbl user)
 {
     try
     {
         using (BeitHamoreProjectEntities db1 = new BeitHamoreProjectEntities())
         {
             db1.Users_Tbl.Add(user);
             db1.SaveChanges();
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Example #13
0
        // GET: Category_Tbl
        public ActionResult Index()
        {
            ViewData["Error"] = "";
            ViewData["ED"]    = "";

            if (Session["id"] != null)
            {
                u = db.Users_Tbl.Find(Session["id"]);
                if (u.RollId == 1)
                {
                    return(View(db.Category_Tbl.ToList()));
                }
                return(RedirectToAction("index", "home"));
            }
            return(RedirectToAction("index", "home"));
        }
Example #14
0
 public ActionResult Index()
 {
     if (Session["id"] != null)
     {
         u = db.Users_Tbl.Find(Session["id"]);
         if (u.RollId == 1)             //for admin
         {
             return(View());
         }
         else if (u.RollId == 2)     //for users
         {
             return(View());
         }
     }
     return(View());                  //for guests
 }
 public ActionResult reportpost(int?id)
 {
     if (Session["id"] != null && id != null)
     {
         Contactus_Tbl cc = new Contactus_Tbl();
         cc.PostId  = id;
         cc.UserId  = Convert.ToInt32(Session["id"]);
         u          = db.Users_Tbl.Find(cc.UserId);
         cc.Email   = u.Email;
         p          = db.Posts_Tbl.Find(id);
         cc.Name    = u.Name + "\t reported \t" + p.PostName;
         cc.Message = "Post Reported:" + cc.PostId.ToString();
         db.Contactus_Tbl.Add(cc);
         db.SaveChanges();
     }
     return(View("Index", db.Posts_Tbl.Where(x => x.Status == "Approved").OrderByDescending(x => x.PostId).ToList().ToPagedList(1, 10)));
 }
        public ActionResult approve(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            u = db.Users_Tbl.Find(id);
            if (u == null)
            {
                return(HttpNotFound());
            }
            u.ApprovalDate    = DateTime.Now.ToString();
            u.Status          = "Approved";
            u.UserId          = Convert.ToInt32(id);
            db.Entry(u).State = EntityState.Modified;
            db.SaveChanges();



            MailMessage mm = new MailMessage("*****@*****.**", u.Email);

            mm.Subject    = "Covert Registration";
            mm.Body       = "Dear " + u.Name + ",\nThank You for registering on covert system. Your account has been approaved. Enjoy posting.\n" + "Regards: COVERT ADMIN";
            mm.IsBodyHtml = false;



            SmtpClient smtp = new SmtpClient();

            smtp.Host      = "smtp.gmail.com";
            smtp.Port      = 587;
            smtp.EnableSsl = true;


            NetworkCredential nc = new NetworkCredential("*****@*****.**", "adminofcovert");

            smtp.UseDefaultCredentials = true;
            smtp.Credentials           = nc;
            smtp.Send(mm);



            return(RedirectToAction("chalan"));
        }
 // GET: Users_Tbl/Create
 public ActionResult Create()
 {
     ViewBag.rollid = new SelectList(db.Roles_Tbl, "RollId", "RollName");
     ViewBag.desid  = new SelectList(db.Designation_Tbl, "DesignationId", "DesignationName");
     ViewBag.areaid = new SelectList(db.Area_Tbl, "AreaId", "AreaName");
     if (Session["id"] != null)
     {
         u = db.Users_Tbl.Find(Session["id"]);
         if (u.RollId == 2)
         {
             return(Redirect("Index"));
         }
         else if (u.RollId == 1)
         {
             return(View());
         }
     }
     return(View());
 }
 // GET: Users_Tbl/Details/5
 public ActionResult Details(int?id)
 {
     if (Session["id"] != null)
     {
         u = db.Users_Tbl.Find(Session["id"]);
         if (u.RollId == 1 || u.UserId == id)
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             Users_Tbl users_Tbl = db.Users_Tbl.Find(id);
             if (users_Tbl == null)
             {
                 return(HttpNotFound());
             }
             return(View(users_Tbl));
         }
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Example #19
0
        // GET: Contactus_Tbl/Edit/5


        // GET: Contactus_Tbl/Delete/5
        public ActionResult Delete(int?id)
        {
            if (Session["id"] != null)
            {
                u = db.Users_Tbl.Find(Session["id"]);
                if (u.RollId == 1)
                {
                    if (id == null)
                    {
                        return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                    }
                    Contactus_Tbl contactus_Tbl = db.Contactus_Tbl.Find(id);
                    if (contactus_Tbl == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(contactus_Tbl));
                }
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
 // GET: Comment_Tbl/Edit/5
 public ActionResult Edit(int?id)
 {
     if (Session["id"] != null)
     {
         c = db.Comment_Tbl.Find(id);
         u = db.Users_Tbl.Find(Session["id"]);
         if (c.UserId == u.UserId || u.RollId == 1)
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             Comment_Tbl comment_Tbl = db.Comment_Tbl.Find(id);
             if (comment_Tbl == null)
             {
                 return(HttpNotFound());
             }
             return(View(comment_Tbl));
         }
         return(RedirectToAction("index", new { id = c.PostId }));
     }
     return(RedirectToAction("index", new { id = c.PostId }));
 }
Example #21
0
 public ActionResult Edit(int?id)
 {
     if (Session["id"] != null)
     {
         u = db.Users_Tbl.Find(Session["id"]);
         if (u.RollId == 1)
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             Category_Tbl category_Tbl = db.Category_Tbl.Find(id);
             if (category_Tbl == null)
             {
                 return(HttpNotFound());
             }
             Session["cat"] = category_Tbl.Name;
             return(View(category_Tbl));
         }
         return(RedirectToAction("index", "home"));
     }
     return(RedirectToAction("index", "home"));
 }
Example #22
0
 public static List <StatusesToUsers_Tbl> Login(Users_Tbl user)
 {
     try
     {
         List <StatusesToUsers_Tbl> list = new List <StatusesToUsers_Tbl>();
         using (BeitHamoreProjectEntities db1 = new BeitHamoreProjectEntities())
         {
             Users_Tbl currentUser = db1.Users_Tbl.FirstOrDefault(u => u.passwordSHA256 == user.passwordSHA256 && u.tz == user.tz);
             if (currentUser == null)
             {
                 return(list.ToList());
             }
             else
             {
                 list = db1.StatusesToUsers_Tbl.Where(stu => stu.userId == currentUser.userId).ToList();
                 return(list.ToList());
             }
         }
     }
     catch (Exception e)
     {
         return(null);
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            int       xx        = 0;
            Users_Tbl users_Tbl = db.Users_Tbl.Find(id);

            try {
                List <Posts_Tbl> pl = db.Posts_Tbl.Where(x => x.UserId == id).ToList();
                foreach (var item in pl)
                {
                    try
                    {
                        List <Comment_Tbl> cl = db.Comment_Tbl.Where(x => x.PostId == item.PostId).ToList();
                        foreach (var comment in cl)
                        {
                            db.Comment_Tbl.Remove(comment);
                        }
                        db.Posts_Tbl.Remove(item);
                    }
                    catch (Exception)
                    {
                        db.Posts_Tbl.Remove(item);
                    }
                }

                try
                {
                    List <Comment_Tbl> cl = db.Comment_Tbl.Where(x => x.UserId == id).ToList();
                    foreach (var comment in cl)
                    {
                        db.Comment_Tbl.Remove(comment);
                    }
                }
                catch (Exception)
                {
                    db.Users_Tbl.Remove(users_Tbl);
                    xx = 1;
                }
            }
            catch (Exception)
            {
                try
                {
                    List <Comment_Tbl> cl = db.Comment_Tbl.Where(x => x.UserId == id).ToList();
                    foreach (var comment in cl)
                    {
                        db.Comment_Tbl.Remove(comment);
                    }
                }
                catch (Exception)
                {
                    db.Users_Tbl.Remove(users_Tbl);
                    xx = 1;
                }
            }

            if (xx == 0)
            {
                db.Users_Tbl.Remove(users_Tbl);
            }
            db.SaveChanges();
            ViewData["Error"] = "Successfully deleted";
            return(View("Index", db.Users_Tbl.Where(x => x.Status == "Approved").ToList().ToPagedList(1, 10)));
        }
        public ActionResult Create(string rollid, string Status, string name, string username, string cnic, string email, string number, string password, string confirmpassword, string desid, string areaid)
        {
            u = db.Users_Tbl.FirstOrDefault(x => x.Username == username || x.Email == email);
            if (u != null)
            {
                ViewBag.desid     = new SelectList(db.Designation_Tbl, "DesignationId", "DesignationName");
                ViewBag.areaid    = new SelectList(db.Area_Tbl, "AreaId", "AreaName");
                ViewBag.rollid    = new SelectList(db.Roles_Tbl, "RollId", "RollName");
                ViewData["Error"] = "Please select some other email or username";
                return(View());
            }
            if (password != confirmpassword)
            {
                ViewBag.desid     = new SelectList(db.Designation_Tbl, "DesignationId", "DesignationName");
                ViewBag.areaid    = new SelectList(db.Area_Tbl, "AreaId", "AreaName");
                ViewBag.rollid    = new SelectList(db.Roles_Tbl, "RollId", "RollName");
                ViewData["Error"] = "Password and confirm password are not matching";
                return(View());
            }
            if (username.Count() < 5 || username.Count() > 12)
            {
                ViewBag.desid     = new SelectList(db.Designation_Tbl, "DesignationId", "DesignationName");
                ViewBag.areaid    = new SelectList(db.Area_Tbl, "AreaId", "AreaName");
                ViewBag.rollid    = new SelectList(db.Roles_Tbl, "RollId", "RollName");
                ViewData["Error"] = "Username should be minimum 5 characters and maximum 12 characters";
                return(View());
            }
            if (password.Count() < 8 || password.Count() > 12)
            {
                ViewBag.desid     = new SelectList(db.Designation_Tbl, "DesignationId", "DesignationName");
                ViewBag.areaid    = new SelectList(db.Area_Tbl, "AreaId", "AreaName");
                ViewBag.rollid    = new SelectList(db.Roles_Tbl, "RollId", "RollName");
                ViewData["Error"] = "Password should be minimum 8 characters and maximum 12 characters";
                return(View());
            }
            u = db.Users_Tbl.FirstOrDefault(x => x.CNIC == cnic);
            if (u != null)
            {
                ViewBag.desid     = new SelectList(db.Designation_Tbl, "DesignationId", "DesignationName");
                ViewBag.areaid    = new SelectList(db.Area_Tbl, "AreaId", "AreaName");
                ViewBag.rollid    = new SelectList(db.Roles_Tbl, "RollId", "RollName");
                ViewData["Error"] = "CNIC already registered";
                return(View());
            }
            if (number.Contains('_'))
            {
                ViewBag.desid     = new SelectList(db.Designation_Tbl, "DesignationId", "DesignationName");
                ViewBag.areaid    = new SelectList(db.Area_Tbl, "AreaId", "AreaName");
                ViewBag.rollid    = new SelectList(db.Roles_Tbl, "RollId", "RollName");
                ViewData["Error"] = "Number Incomplete";
                return(View());
            }
            if (cnic.Contains('_'))
            {
                ViewBag.desid     = new SelectList(db.Designation_Tbl, "DesignationId", "DesignationName");
                ViewBag.areaid    = new SelectList(db.Area_Tbl, "AreaId", "AreaName");
                ViewBag.rollid    = new SelectList(db.Roles_Tbl, "RollId", "RollName");
                ViewData["Error"] = "CNIC Incomplete";
                return(View());
            }
            if (areaid == "")
            {
                ViewBag.desid     = new SelectList(db.Designation_Tbl, "DesignationId", "DesignationName");
                ViewBag.areaid    = new SelectList(db.Area_Tbl, "AreaId", "AreaName");
                ViewBag.rollid    = new SelectList(db.Roles_Tbl, "RollId", "RollName");
                ViewData["Error"] = "Please Select an area";
                return(View());
            }


            else
            {
                Users_Tbl users_Tbl = new Users_Tbl();



                if (Session["id"] == null)
                {
                    users_Tbl.RollId = 2;
                    users_Tbl.Status = "Pending";
                }
                else
                {
                    u = db.Users_Tbl.Find(Session["id"]);
                    if (u.RollId == 1)
                    {
                        if (rollid != "")
                        {
                            users_Tbl.RollId = Convert.ToInt32(rollid);
                        }
                        else
                        {
                            users_Tbl.RollId = 2;
                        }
                        if (Status != "")
                        {
                            users_Tbl.Status = Status;
                        }
                        else
                        {
                            users_Tbl.Status = "Pending";
                        }
                        if (desid != "" && users_Tbl.RollId == 1)
                        {
                            users_Tbl.DesignationId = Convert.ToInt32(desid);
                        }
                        else
                        {
                            users_Tbl.DesignationId = 2;
                        }
                    }
                }
                users_Tbl.SignUpDate = DateTime.Now.ToString();
                if (users_Tbl.Status == "Pending")
                {
                    users_Tbl.ApprovalDate = null;
                }
                else
                {
                    users_Tbl.ApprovalDate = DateTime.Now.ToString();
                }
                users_Tbl.AreaId   = Convert.ToInt32(areaid);
                users_Tbl.Username = username;
                users_Tbl.Name     = name;
                users_Tbl.CNIC     = cnic;
                users_Tbl.Email    = email;
                users_Tbl.Number   = number;
                users_Tbl.Password = password;

                db.Users_Tbl.Add(users_Tbl);
                db.SaveChanges();
                MailMessage mm = new MailMessage("*****@*****.**", users_Tbl.Email);
                mm.Subject    = "Covert Registration";
                mm.Body       = "Dear " + users_Tbl.Name + ",\nThank You for registering on covert system. Your account has been created. You will shortly be approved. \n" + "Regards: COVERT ADMIN";
                mm.IsBodyHtml = false;



                SmtpClient smtp = new SmtpClient();
                smtp.Host      = "smtp.gmail.com";
                smtp.Port      = 587;
                smtp.EnableSsl = true;


                NetworkCredential nc = new NetworkCredential("*****@*****.**", "adminofcovert");
                smtp.UseDefaultCredentials = true;
                smtp.Credentials           = nc;
                smtp.Send(mm);
                if (u != null)
                {
                    if (u.RollId == 1)
                    {
                        ViewData["Error"] = "Successfully added";
                        return(View("Index", db.Users_Tbl.Where(x => x.Status == "Approved").ToList().ToPagedList(1, 10)));
                    }
                }

                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult Create(string categoryid, string name, string Description, string areaid)
        {
            Posts_Tbl posts_Tbl = new Posts_Tbl();

            if (categoryid == "")
            {
                ViewData["Error"]  = "PLAESE SELECT A CATAGORY";
                ViewBag.categoryid = new SelectList(db.Category_Tbl, "categoryid", "Name");
                ViewBag.areaid     = new SelectList(db.Area_Tbl, "Areaid", "AreaName");

                return(View());
            }
            if (areaid == "")
            {
                ViewData["Error"]  = "PLAESE SELECT AN AREA";
                ViewBag.categoryid = new SelectList(db.Category_Tbl, "categoryid", "Name");
                ViewBag.areaid     = new SelectList(db.Area_Tbl, "Areaid", "AreaName");

                return(View());
            }
            posts_Tbl.PostName        = name;
            posts_Tbl.PostDescription = Description;
            posts_Tbl.CategoryId      = Convert.ToInt32(categoryid);
            posts_Tbl.AreaId          = Convert.ToInt32(areaid);
            posts_Tbl.UserId          = Convert.ToInt32(Session["id"]);
            posts_Tbl.PostDate        = DateTime.Now.ToString();

            if (string.IsNullOrEmpty(Request.Files[0].FileName))
            {
                List <string> match = new List <string>()
                {
                    "Abuse", "abuse", "Accessory", "accessory", "Accomplice", "accomplice", "Accused", "accused", "Accuser", "accuser",
                    "Activists", "activists", "Adversary", "adversary", "Affect", "affect", "AFIS", "Against", "against", "Agency", "agency", "Aggravated", "aggravated", "assault", "Assault",
                    "Alarm", "alarm", "Alcohol", "alcohol", "Alert", "alert", "Alias", "alias", "Alibi", "alibi", "Alienate", "alienate", "Allegation", "allegation", "Ammunition", "ammunition",
                    "APB", "Appeal", "appeal", "Armed", "armed", "Arraignment", "arraignment", "Arrest", "arrest", "Arsenal", "arsenal", "Arson", "arson", "Art forgery", "Art Forgery", "art forgery",
                    "Assailant", "assailant", "Attack", "attack", "Authority", "authority", "Autopsy", "autopsy", "Background check", "Background Check", "background check", "check", "Check",
                    "Backup", "backup", "Bail", "bail", "Ballistics", "ballistics", "Battery", "battery", "Beat", "beat", "Behavior", "behavior", "Behind bars", "behind bars", "Behind Bars",
                    "Belligerence", "belligerence", "Big house", "Big House", "big house", "Blackmail", "blackmail", "Bloodstain", "bloodstain", "Blood", "blood", "Bombing", "Bombing",
                    "Brawl", "brawl", "Breach", "breach", "Break-in", "break-in", "Broke-in", "broke-in", "broke-into", "Broke-into", "broke", "Broke", "Break", "break", "Breaking and entering",
                    "breaking and entering", "Breaking and Entering", "Bribery", "bribery", "Brutality", "Bullying", "bullying", "brutality", "Burden of proof", "Burden of Proof", "burden of proof",
                    "Burglary", "burglary", "Bystander", "bystander", "Capture", "capture", "case", "Case", "Caution", "caution", "Chase", "chase", "Cheat", "cheat", "Civil", "civil", "Claim", "claim",
                    "Coercion", "coercion", "Collusion", "collusion", "Combat", "combat", "Commission", "commission", "Commit", "commit", "Complaint", "complaint", "Complication", "complication",
                    "Conduct", "conduct", "Confession", "confession", "Connection", "connection", "Conspiracy", "conspiracy", "Contact", "contact", "Contempt", "contempt", "Control", "control",
                    "Controversial", "controversial", "Conviction", "conviction", "Cops", "cops", "Coroner", "coroner", "Corruption", "corruption", "Counsel", "counsel", "Counterfeit", "counterfeit",
                    "Credit theft", "Credit Theft", "credit theft", "Crime", "crime", "Criminal", "criminal", "justice", "Justice", "Criminology", "criminology", "Cuffs", "cuffs", "Custody", "custody",
                    "Damage", "damage", "Danger", "danger", "Dangerous", "dangerous", "Dark side", "Dark Side", "dark side", "Deadly", "deadly", "Deal", "deal", "Dealings", "dealings", "Death", "death",
                    "Deed", "deed", "Defendant", "defendant", "Defense", "defense", "Deliberate", "deliberate", "Delinquency", "delinquency", "Democratic", "democratic", "Denial", "denial", "Department",
                    "department", "Deputy", "deputy", "Detail", "detail", "Detain", "detain", "Detection", "detection", "Detective", "detective", "Deter", "deter", "Determination", "determination", "Deviant",
                    "deviant", "Direct", "direct", "Discovery", "discovery", "Dismember", "dismember", "Disobedience", "disobedience", "Disorderly", "disorderly", "Dispatch", "dispatch", "Disregard", "disregard",
                    "Disruption", "disruption", "attorney", "Attorney", "DNA", "domestic", "Domestic", "Document", "document", "Dossier", "dossier", "Drill", "drill", "Drugs", "drugs", "Duty", "duty",
                    "Educate", "educate", "Education", "education", "Effect", "effect", "Elusive", "elusive", "Embezzle", "Emergency", "emergency", "embezzle", "Enable", "enable", "Encumber", "encumber",
                    "Enforce", "enforce", "Entail", "entail", "Equality", "equality", "Escape", "escape", "Ethical", "ethical", "Evasive", "evasive", "Eviction", "Evidence", "evidence", "eviction", "Evil", "evil",
                    "Examination", "examination", "Execute", "execute", "Exonerate", "exonerate", "Expert", "expert", "Explosives", "explosives", "Expunge", "expunge", "Extort", "extort", "Extradition",
                    "extradition", "Extreme", "extreme", "Failure", "failure", "Fairness", "fairness", "Fatality", "fatality", "Fault", "fault", "Family", "family", "FBI", "Federal", "federal", "Felony", "felony",
                    "Ferocity", "ferocity", "Fight", "fight", "Fine", "fine", "Fingerprint", "fingerprint", "Bomb", "bomb", "First-degree", "first-degree", "First-Degree", "Flee", "flee", "Footprints", "footprints",
                    "Forbidden", "forbidden", "Force", "force", "Forensics", "forensics", "Forgery", "forgery", "Formal charge", "formal charge", "Formal Charge", "Frantic", "frantic", "Fraud", "fraud", "Freedom",
                    "freedom", "Full-scale", "Full-Scale", "full-scale", "Fundamental", "fundamental", "Furtive", "furtive", "Good guys", "good guys", "Good Guys", "Gory", "gory", "Government", "government", "Grief",
                    "grief", "Grievance", "grievance", "Guarantee", "guarantee", "Guard", "guard", "Guilt", "guilt", "Gun", "gun", "Hand-to-hand", "hand-to-hand", "Hand-to-Hand", "Handcuffs", "handcuffs", "Handle",
                    "handle", "Harassment", "harassment", "Harassing", "harassing", "Harm", "harm", "Headquarters", "headquarters", "Heinous", "heinous", "Helicopter", "helicopter", "Help", "help", "rifle", "Rifle",
                    "High-profile", "high-profile", "High-Profile", "Hijack", "hijack", "Hire", "hire", "Holding cell", "holding cell", "Holding Cell", "Holster", "holster", "Homicide", "homicide", "Honesty",
                    "honesty", "Honor", "honor", "Hostage", "hostage", "Hot-line", "hot-line", "Hot-Line", "Humanity", "humanity", "Identification", "identification", "Illegal", "illegal", "Immoral", "immoral",
                    "Immunity", "immunity", "Impeach", "impeach", "Impression", "impression", "Prison", "prison", "Improper", "improper", "Incarceration", "incarceration", "Competent", "competent",
                    "Incriminating", "incriminating", "Indictment", "indictment", "Influence", "influence", "Informant", "informant", "Information", "information", "Initiative", "initiative", "Injury", "injury",
                    "Injure", "injure", "Inmate", "inmate", "Innocence", "innocence", "innocent", "Innocent", "Inquest", "inquest", "Instruct", "instruct", "Integrity", "integrity", "Intelligence", "intelligence",
                    "Interests", "interests", "Interference", "interference", "national", "National", "Central", "central", "Fedral", "fedral", "Local", "local", "Interpol", "interpol", "interpret", "Interpret",
                    "Interrogate", "interrogate", "Interstate", "interstate", "Intervention", "intervention", "Interview", "interview", "Intrastate", "intrastate", "Intruder", "intruder", "Invasive", "invasive",
                    "Investigate", "investigate", "Investigation", "investigation", "Irregular", "irregular", "Firring", "firring", "Fire", "fire", "Irresponsible", "irresponsible", "Issue", "issue", "Jail", "jail",
                    "Judge", "judge", "Judgment", "judgment", "Judicial", "judicial", "Judiciary", "judiciary", "Jurisdiction", "jurisdiction", "Jury", "jury", "Justice", "justice", "Juvenile", "juvenile", "Kidnap",
                    "kidnap", "Kill", "kill", "Kin", "kin", "Laboratory", "laboratory", "Larceny", "larceny", "Law", "law", "Leaks", "leaks", "Lease", "lease", "legal", "Legal", "Legislation", "legislation",
                    "Legislation", "legislation", "Legislature", "legislature", "Lethal", "lethal", "Libel", "libel", "Liberty", "liberty", "License", "license", "Lie", "lie", "Limits", "limits", "Long hours",
                    "Long Hours", "long hours", "Lowlife", "lowlife", "Loyal", "loyal", "Lynch", "lynch", "Mace", "mace", "Maintain", "maintain", "Major", "major", "Malice", "malice", "Mal", "mal", "Manacled",
                    "manacled", "Manslaughter", "manslaughter", "Marshal", "marshal", "Mayhem", "mayhem", "detector", "Detector", "Detective", "detective", "Minor", "minor", "Miscreant", "miscreant",
                    "Misdemeanor", "misdemeanor", "Missing", "missing", "Mission", "mission", "Model", "model", "Money laundering", "money laundering", "Money Laundering", "Moratorium", "moratorium",
                    "Motorist", "motorist", "Murder", "murder", "Negligent", "negligent", "Negotiable", "negotiable", "neglible", "Neglible", "Negotiate", "negotiate", "Neighborhood", "neighborhood",
                    "Network", "network", "Taliban", "taliban", "Terrorist", "terrorist", "Notation", "notation", "Notification", "notification", "Nuisance", "nuisance", "Oath", "oath", "Obey", "obey",
                    "Obligation", "obligation", "Offender", "offender", "Offense", "offense", "Officer", "officer", "Official", "official", "Case", "case", "Opinion", "opinion", "Opportunity", "opportunity",
                    "Order", "order", "Organize", "organize", "Ownership", "ownership", "Partner", "partner", "Partnership", "partnership", "Pathology", "pathology", "Patrol", "patrol", "Pattern", "pattern",
                    "Pedestrian", "pedestrian", "Peeping Tom", "peeping tom", "Peeping tom", "Penalize", "penalize", "Penalty", "penalty", "Perjury", "perjury", "Perpetrator", "perpetrator", "Petition", "petition",
                    "theft", "Theft", "Phony", "phony", "Plainclothes officer", "plainclothes officer", "Plainclothes Officer", "Plea", "plea", "Police", "police", "Policy", "policy", "Power", "power",
                    "Precedent", "precedent", "Precinct", "precinct", "Preliminary findings", "preliminary findings", "Preliminary Findings", "Prevention", "prevention", "Principle", "principle", "Prior", "prior",
                    "Prison", "prison", "Private", "private", "Probable cause", "probable cause", "Probable Cause", "Probation", "probation", "Procedure", "procedure", "Professional", "professional",
                    "Profile", "profile", "Prohibit", "prohibit", "Proof", "proof", "Property", "property", "Prosecute", "prosecute", "Prosecutor", "prosecutor", "Prostitution", "prostitution", "Protection",
                    "protection", "Protocol", "protocol", "Provision", "provision", "Public", "public", "Punish", "punish", "Quake", "quake", "Qualification", "qualification", "Quality", "quality",
                    "Quantify", "quantify", "Quantity", "quantity", "Quarrel", "quarrel", "Quell", "quell", "Question", "question", "Quickly", "quickly", "Quirk", "quirk", "Quiver", "quiver", "Radar", "radar",
                    "Raid", "raid", "Rank", "rank", "Rap", "rap", "Reason", "reason", "Reckless", "reckless", "Record", "record", "Recovery", "recovery", "Recruit", "recruit", "Redress", "redress", "Reduction",
                    "reduction", "Refute", "refute", "Register", "register", "Regulations", "regulations", "Reinforce", "reinforce", "Reject", "reject", "Release", "release", "Repeal", "repeal",
                    "Report", "report", "Reprobate", "reprobate", "Reputation", "reputation", "Require", "require", "Resist", "resist", "Responsibility", "responsibility", "Restitution",
                    "restitution", "Restrain", "restrain", "Restriction", "restriction", "Revenge", "revenge", "Rights", "rights", "Riot", "riot", "Robbery", "robbery", "Rogue", "rogue", "Rough", "rough",
                    "Rules", "rules", "Rulings", "rulings", "Sabotage", "sabotage", "Safeguard", "safeguard", "Sanction", "sanction", "Scene", "scene", "Sealed", "sealed", "Search", "search", "Rescue", "rescue",
                    "Secret", "secret", "Team", "team", "Seize", "seize", "Seizure", "seizure", "Selection", "selection", "Sentence", "sentence", "Sergeant", "sergeant", "Serial", "serial", "killer", "Killer",
                    "Seriousness", "seriousness", "Services", "services", "Sex", "sex", "Crime", "crime", "Shackles", "shackles", "Sheriff", "sheriff", "Shoot", "shoot", "Shyster", "shyster", "Sighting",
                    "sighting", "Situation", "situation", "Skillful", "skillful", "Slander", "slander", "Slash", "slash", "Slay", "slay", "Smuggl", "smuggl", "Sorrow", "sorrow", "Speculation", "speculation",
                    "Spying", "spying", "Squad", "squad", "Stabbing", "stabbing", "Stalking", "stalking", "Statute", "statute", "Stigma", "stigma", "Limit", "limit", "Stipulation", "stipulation", "Subdue", "subdue",
                    "Subpoena", "subpoena", "Successful", "successful", "Summons", "summons", "Supervise", "supervise", "Suppress", "suppress", "Surveillance", "surveillance", "Survivor", "survivor",
                    "Suspect", "suspect", "Suspicion", "suspicion", "Suspicious", "suspicious", "Sworn", "sworn", "System", "system", "Tactic", "tactic", "Task", "task", "Force", "force", "Terrorism", "terrorism",
                    "Test", "test", "Theft", "theft", "Threatening", "threatening", "Three-strikes law", "three-strikes law", "Three-Strikes Law", "Thwart", "thwart", "Tire-slashing", "Tire-Slashing", "tire-slashing",
                    "Torture", "torture", "Toxic", "toxic", "Trace", "trace", "Traffic", "traffic", "Tragedy", "tragedy", "Transfer", "transfer", "Trauma", "trauma", "Treat", "treat", "Trespass", "trespass", "Trial", "trial",
                    "Troop", "troop", "Trust", "trust", "Unacceptable", "unacceptable", "Unauthorized", "unauthorized", "Unclaimed", "unclaimed", "Unconstitutional", "unconstitutional", "Undercover", "undercover",
                    "Underpaid", "underpaid", "Understaffed", "understaffed", "Unexpected", "unexpected", "Unharmed", "unharmed", "Uniform", "uniform", "Unintentional", "unintentional", "Unit", "unit", "Unjust", "unjust",
                    "Unknown", "unknown", "Unlawful", "unlawful", "Unsolved", "unsolved", "Uphold", "uphold", "Vagrancy", "vagrancy", "Vandalism", "vandalism", "Viable", "viable", "Vice", "vice", "Victim", "victim", "Victory",
                    "victory", "Vigilance", "vigilance", "Vigilante", "vigilante", "Violate", "violate", "Violation", "violation", "Violence", "violence", "Volunteer", "volunteer", "Vow", "vow", "Voyeurism", "voyeurism",
                    "Vulnerable", "vulnerable", "Wanted", "wanted", "Poster", "poster", "Ward", "ward", "Warn", "warn", "Warped", "warped", "Warrant", "warrant", "Watch", "watch", "Weapon", "weapon", "Will", "will", "Wiretap",
                    "wiretap", "Wisdom", "wisdom", "Witness", "witness", "Worse", "worse", "Wrong", "wrong", "youth", "Youth", "Zeal", "zeal"
                };
                if (match.Any(posts_Tbl.PostName.Contains) && match.Any(posts_Tbl.PostDescription.Contains))
                {
                    posts_Tbl.Status       = "Approved";
                    posts_Tbl.ApprovalDate = DateTime.Now.ToString();
                    db.Posts_Tbl.Add(posts_Tbl);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    posts_Tbl.Status       = "Pending";
                    posts_Tbl.ApprovalDate = null;
                    db.Posts_Tbl.Add(posts_Tbl);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            u = db.Users_Tbl.Find(posts_Tbl.UserId);
            if (u.RollId != 1)
            {
                posts_Tbl.Status       = "Pending";
                posts_Tbl.ApprovalDate = null;
            }
            else
            {
                posts_Tbl.Status       = "Approved";
                posts_Tbl.ApprovalDate = DateTime.Now.ToString();
            }



            db.Posts_Tbl.Add(posts_Tbl);
            db.SaveChanges();

            var rn = Guid.NewGuid().ToString();
            //string dateobj = DateTime.Now.ToString();
            int counter = 0, x = -1;

            foreach (string fileName in Request.Files)
            {
                x++;
                HttpPostedFileBase file = Request.Files[x];
                if (!string.IsNullOrEmpty(file.FileName))
                {
                    string url  = "~/Images/" + rn + (counter++).ToString() + file.FileName.Substring(file.FileName.LastIndexOf('.'));
                    string path = Server.MapPath(url);
                    file.SaveAs(path);
                    Visual_Tbl item = new Visual_Tbl();
                    item.Url    = url;
                    item.PostId = posts_Tbl.PostId;
                    item.UserId = posts_Tbl.UserId;
                    db.Visual_Tbl.Add(item);
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("Index"));
        }