private void SetItems(string task, ObjectifViewModel objVm)
        {
            ObjectifType type = objCtx.GetObjectifTypeByName(task);

            objVm.Items = objCtx.GetItems(type.Id).Select(a => a.Name).Distinct().ToList();
            objVm.Type  = task;
        }
        public ActionResult AddTask(ObjectifViewModel objVm)
        {
            string type = objVm.Type;

            if (ModelState.IsValid)
            {
                ObjectifType objectifType = objCtx.GetObjectifTypeByName(type);
                objectifType.Items = new List <Item>();

                if (!objVm.Items.Contains(objVm.Tache))
                {
                    objectifType.Items.Add(new Item {
                        Name = objVm.Tache
                    });
                }

                var objectif = new Objectif
                {
                    Date        = objVm.Date,
                    NbPoint     = objVm.NbPoint,
                    ObjTypeId   = objectifType.Id,
                    Commentaire = objVm.Commentaire,
                    UserId      = userCtx.GetUserIdWhithName(User.Identity.Name),
                    Tache       = objVm.Tache
                };

                objCtx.AddObjectif(objectif);
                objVm.Objectifs   = objCtx.GetObjectifsByType(type);
                objVm.Commentaire = string.Empty;
                objVm.Date        = DateTime.Now;
                objVm.NbPoint     = 0;
            }
            else
            {
                objVm.Date    = DateTime.Now;
                objVm.isValid = false;
            }
            initViewModel(objVm, type);
            return(View("Objectif", objVm));
        }