public ActionResult Delete(int id)
 {
     try
     {
         var model = reposatoryelement.Find(id);
         if (model != null)
         {
             return(View(model));
         }
         else
         {
             TempData["Message"] = HR.Resource.pers_2.Faild;
             return(RedirectToAction("index"));
         }
     }
     catch (Exception)
     {
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult Create(FormCollection form, PerformanceEvaluationGroup model, string Command)
        {
            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.AddOne(model);

                var ID_Q = form["ID_Q"].Split(',');
                for (var i = 0; i < ID_Q.Count(); i++)
                {
                    if (ID_Q[i] != "")
                    {
                        var id = int.Parse(ID_Q[i]);
                        var q  = reposatoryQuestions.Find(id);
                        var F  = reposatoryEvaluationPerformance.addManytoMantquestions(new Questions_Performance {
                            EvaluationQuestionsandanswersID = q.ID, PerformanceEvaluationGroupID = obj.ID
                        });
                    }
                }
                var ID_element = form["ID_Element"].Split(',');
                for (var i = 0; i < ID_element.Count(); i++)
                {
                    if (ID_element[i] != "")
                    {
                        var id      = int.Parse(ID_element[i]);
                        var element = reposatoryElements.Find(id);
                        var F       = reposatoryEvaluationPerformance.addManytoMantTable(new PerformanceEvaluationGroupEvaluationElements {
                            EvaluationElementsID = element.ID, PerformanceEvaluationGroupID = obj.ID
                        });
                    }
                }

                if (obj != null)
                {
                    TempData["Message"] = HR.Resource.pers_2.addedSuccessfully;
                    //=================================check for alert==================================
                    var get_result_check = HR.Controllers.check.check_alert("evalution group card", HR.Models.user.Action.Create, HR.Models.user.type_field.form);
                    if (get_result_check != null)
                    {
                        var inbox = new Models.user.Alert_inbox {
                            send_from_user_id = User.Identity.Name, send_to_user_id = get_result_check.send_to_ID_user, title = get_result_check.Subject, Subject = get_result_check.Message
                        };
                        if (get_result_check.until != null)
                        {
                            if (get_result_check.until.Value.Year != 0001)
                            {
                                inbox.until = get_result_check.until;
                            }
                        }
                        ApplicationDbContext dbcontext = new ApplicationDbContext();
                        dbcontext.Alert_inbox.Add(inbox);
                        dbcontext.SaveChanges();
                    }
                    //==================================================================================
                    return(RedirectToAction("index"));
                }
                else
                {
                    TempData["Message"] = HR.Resource.pers_2.Faild; return(View(model));
                }
            }
            catch (Exception e)
            {
                TempData["Message"] = HR.Resource.pers_2.Faild;
                return(View(model));
            }
        }