public ActionResult Create(Function_Role_Map function_role_map)
        {
            string dtNow = Convert.ToDateTime(DateTime.Now.ToString()).ToString("yyyy-MM-dd");

            if (ModelState.IsValid)
            {
                //delete existing data
                var deleteExistingData = from details in db.Function_Role_Map where details.role_id == function_role_map.role_id select details;
                foreach (var detail in deleteExistingData)
                {
                    db.Function_Role_Map.Remove(detail);
                }
                db.SaveChanges();

                //save new

                if (!string.IsNullOrEmpty(Request.Form["rolefunction"]))
                {
                    string[] temp = Request.Form["rolefunction"].Split(',');
                    for (int i = 0; i < temp.Count(); i++)
                    {
                        function_role_map.function_id = int.Parse(temp[i].ToString());
                        function_role_map.status_id = 1;
                        function_role_map.created_date = dtNow;
                        function_role_map.updated_date = dtNow;
                        db.Function_Role_Map.Add(function_role_map);
                        db.SaveChanges();
                        TempData["errorMessage"] = "Role Maped Successfully";
                    }
                }
                return RedirectToAction("Index");
            }
            return RedirectToAction("Index");
        }
 public ActionResult DbSearchresult(Function_Role_Map function_role_map)
 {
     if (function_role_map.role_id != 0)
     {
         var result = from r in db.Roles
                      where r.role_id == function_role_map.role_id
                      select new Function_Role_MapModel { role_name = r.role_name, role_id = r.role_id };
         return View("Index", result.ToList());
     }
     return RedirectToAction("Index");
 }
 public ActionResult DbSearchresult(Function_Role_Map function_role_map)
 {
     if (Session["login_status"] != null)
     {
         int[] z = (int[])Session["function_id"];
         if (z.Contains(6))
         {
             if (function_role_map.role_id != 0)
             {
                 var result = from r in db.Roles
                              where r.role_id == function_role_map.role_id
                              select new Function_Role_MapModel { role_name = r.role_name, role_id = r.role_id };
                 return View("Index", result.ToList());
             }
             return RedirectToAction("Index");
         }
         else
         {
             return RedirectToAction("../Home/Dashboard");
         }
     }
     else
     {
         return RedirectToAction("../Home");
     }
 }