public ActionResult Edit(int id)
 {
     try
     {
         ViewBag.QA       = reposatoryQuestions.GetAll().Select(m => new { ID = m.ID, Code = m.Code + "->" + m.Question });
         ViewBag.elements = reposatoryElements.GetAll().Select(m => new { ID = m.ID, Code = m.Code + "->" + m.Name });
         var obj = reposatoryEvaluationPerformance.Find(id);
         if (obj.EvaluationQuestionsandanswers != null)
         {
             foreach (var item in obj.EvaluationQuestionsandanswers)
             {
                 item.EvaluationQuestionsandanswers = reposatoryQuestions.Find(item.EvaluationQuestionsandanswersID);
             }
         }
         if (obj != null)
         {
             return(View(obj));
         }
         else
         {
             return(RedirectToAction("index"));
         }
     }
     catch (Exception)
     {
         TempData["Message"] = HR.Resource.pers_2.Faild;
         return(RedirectToAction("index"));
     }
 }
        public ActionResult editTide_Emp_With_performance(FormCollection form, per_em model)
        {
            try
            {
                var context = new ApplicationDbContext();
                List <SelectListItem> items = new List <SelectListItem>();
                items.Insert(0, (new SelectListItem
                {
                    Text = "employee",
                    Value = "1",
                }));
                items.Insert(1, (new SelectListItem
                {
                    Text = "unit",
                    Value = "2",
                }));
                items.Insert(2, (new SelectListItem
                {
                    Text = "nationality",
                    Value = "3",
                }));
                ViewBag.Object = new SelectList(items, "Value", "Text");

                var per     = reposatoryEvaluationplan.Find(model.PER_id);
                var per_em1 = context.per_emp.Where(m => m.PerformanceEvaluationGroupID == model.PER_id).ToList();
                context.per_emp.RemoveRange(per_em1);
                context.SaveChanges();

                //var model = context.per_emp.Where(m => m.PerformanceEvaluationGroupID == ID).ToList();


                var ID_emp = form["ID_emp"].Split(',');
                var per2   = reposatoryEvaluationPerformance.Find(model.PER_id);
                foreach (var item in ID_emp)
                {
                    if (item != "")
                    {
                        var ID     = int.Parse(item);
                        var per_em = new per_emp();
                        var emp    = context.Employee_Profile.FirstOrDefault(m => m.ID == ID);
                        per_em.PerformanceEvaluationGroupID = per.ID;
                        per_em.Employee_ProfileID           = emp.ID;
                        var record = context.per_emp.Add(per_em);
                        context.SaveChanges();
                    }
                }

                return(RedirectToAction("Edit", new { id = per.ID }));
            }
            catch (Exception)
            {
                return(View());
            }
        }