Ejemplo n.º 1
0
        public JsonResult DeleteChoix(int idChoix)
        {
            Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("deleteChoix.Choix.Entrée(idChoix: {0})", idChoix));
            var             pothImage = Path.Combine(Server.MapPath(ConfigHelper._CST_DIRECTORY_IMAGE));
            MediaController med       = new MediaController();
            var             choix     = DALChoix.FindById(idChoix);

            try
            {
                if (choix.image_id != null)
                {
                    med.DeleteImage((int)choix.image_id, pothImage);
                    DALMedia.DeleteImage((int)choix.image_id);
                }
                DALChoix.DeleteChoix(idChoix);
            }
            catch (Exception e)
            {
                Tools.Logger.Ecrire(Tools.Logger.Niveau.Erreur, string.Format("deleteChoix.Choix.Exception(Exception: {0})", e));
                return(Json(ErrorList.deleteChoix));
            }



            return(Json(1));
        }
Ejemplo n.º 2
0
        /**
         * Delete question ave l'Id de la question
         */
        public ActionResult DeleteQuestion(int id)
        {
            MediaController med       = new MediaController();
            var             pothImage = Path.Combine(Server.MapPath(ConfigHelper._CST_DIRECTORY_IMAGE));

            Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("DeleteQuestion.Question.Entrée(idElement : {0})", id));
            var idQuestionnaire = 0;

            try
            {
                Elements element = DALElement.FindById(id);
                idQuestionnaire = (int)element.questionnaire_id;
                if (DALMedia.SelectVeryAllFromElement(id) != null)
                {
                    foreach (var image in DALMedia.SelectVeryAllFromElement(id))
                    {
                        med.DeleteImage(image.Id, pothImage);
                    }
                }

                if (DALChoix.SelectAllByElement(id) != null)
                {
                    foreach (var choix in DALChoix.SelectAllByElement(id))
                    {
                        if (choix.image_id != null)
                        {
                            med.DeleteImage((int)choix.image_id, pothImage);
                        }
                    }
                }
                DALElement.DeleteElement(element.Id);
            }
            catch (Exception e)
            {
                Tools.Logger.Ecrire(Tools.Logger.Niveau.Erreur, string.Format("DeleteQuestion.Question.Sortie(idQuestionnaire: {0})", idQuestionnaire));
                return(RedirectToAction("PageCreateQuestionnaire", "Questionnaire", new { id = idQuestionnaire, erreur = ErrorList.deleteQuestion }));
            }

            Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("DeleteQuestion.Question.Sortie(idQuestionnaire: {0})", idQuestionnaire));

            return(RedirectToAction("PageCreateQuestionnaire", "Questionnaire", new { id = idQuestionnaire }));
        }
Ejemplo n.º 3
0
        /**
         * Va effacer un élément puis réactualiser la page createQuestionnaire. Possible amélioration en
         * la mettant en Asyn avec Jquery
         */
        public ActionResult DeleteElement(int id)
        {
            MediaController med = new MediaController();

            Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("DeleteDescription.Description.Entrée(idQuestionnaire : {0})", id));
            var      pothImage = Path.Combine(Server.MapPath(ConfigHelper._CST_DIRECTORY_IMAGE));
            var      pothVideo = Path.Combine(Server.MapPath(ConfigHelper._CST_DIRECTORY_VIDEO));
            Elements element   = new Elements();

            try
            {
                element = DALElement.FindById(id);
                if (DALMedia.SelectVeryAllFromElement(id) != null)
                {
                    foreach (var image in DALMedia.SelectVeryAllFromElement(id))
                    {
                        med.DeleteImage(image.Id, pothImage);
                    }
                }

                if (DALMedia.SelectVideoFromElement(id) != null)
                {
                    med.DeleteVideo(DALMedia.SelectVideoFromElement(id).Id, pothVideo);
                }
                DALElement.DeleteElement(element.Id);
            }
            catch (Exception e)
            {
                Tools.Logger.Ecrire(Tools.Logger.Niveau.Erreur, string.Format("DeleteDescription.Description.Exception(Exception : {0})", e));
                return(RedirectToAction("PageCreateQuestionnaire", "Questionnaire", new{ id = id, error = ErrorList.deleteDescription }));
            }

            Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("DeleteDescription.Description.Sortie(idQuestionnaire : {0})", element.questionnaire_id));

            return(RedirectToAction("PageCreateQuestionnaire", "Questionnaire", new { id = element.questionnaire_id }));
        }
Ejemplo n.º 4
0
        /**
         * Fonction delete appelé en Jquery
         */
        public JsonResult DeleteQuestionnaireJquery(int idQuestionnaire)
        {
            Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("DeleteQuestionnaire.Questionnaire.Entrée({0})", idQuestionnaire));
            MediaController med       = new MediaController();
            var             pothImage = Path.Combine(Server.MapPath(_CST_DIRECTORY_IMAGE));
            var             pothVideo = Path.Combine(Server.MapPath(_CST_DIRECTORY_VIDEO));

            try
            {
                var questionnaire = DALQuestionnaire.FindById(idQuestionnaire);
                if (DALElement.SelectAllQuestionFromQuestionnaire(idQuestionnaire) != null)
                {
                    var elements = DALElement.SelectAllFromQuestionnaire(idQuestionnaire);
                    foreach (var element in elements)
                    {
                        if (DALMedia.SelectAllFromElement(element.Id) != null)
                        {
                            var images = DALMedia.SelectAllFromElement(element.Id);
                            foreach (var image in images)
                            {
                                med.DeleteImage(image.Id, pothImage);
                            }
                        }

                        if (DALMedia.SelectVideoFromElement(element.Id) != null)
                        {
                            med.DeleteVideo(DALMedia.SelectVideoFromElement(element.Id).Id, pothVideo);
                        }

                        if (element.TypeElement_Id == 2)
                        {
                            if (DALChoix.SelectAllByElement(element.Id) != null)
                            {
                                var choix = DALChoix.SelectAllByElement(element.Id);
                                foreach (var c in choix)
                                {
                                    if (c.image_id != null)
                                    {
                                        med.DeleteImage((int)c.image_id, pothImage);
                                    }
                                }
                            }
                        }
                    }
                }
                DALQuestionnaire.DeleteQuestionnaire(idQuestionnaire);
            }
            catch (Exception e)
            {
                Tools.Logger.Ecrire(Tools.Logger.Niveau.Erreur, string.Format("DeleteQestionnaireJquery.Questionnaire.Exception(idquestionnaire : {0})", idQuestionnaire));
                //return RedirectToAction("ListeQuestionnaires", "Questionnaire", new { erreur = ErrorList.intituleQuestionnaire });
                return(Json(new
                {
                    redirectUrl = Url.Action("ListeQuestionnaires", "Questionnaire", new { erreur = ErrorList.deleteQuestionnaire }),
                    isRedirect = true
                }));
            }
            Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("DeleteQuestionnaire.Questionnaire.Sortie(idQuestionnaire : {0})", idQuestionnaire));

            return(Json(new
            {
                redirectUrl = Url.Action("ListeQuestionnaires", "Questionnaire"),
                isRedirect = true
            }));
        }