示例#1
0
        // GET: Surveys/Create
        public ActionResult Create(string error)
        {
            if (AccountController.CheckPermission("Survey-Create"))
            {
                if (error != null)
                {
                    ModelState.AddModelError("Questions", error);
                }
                UpdateList();
                System.Web.HttpContext.Current.Session["action"] = "Survey-Create";
                if (AccountController.CheckSession("Edit"))
                {
                    ViewBag.edit = true;
                    AccountController.ClearSession("Edit");
                }
                else
                {
                    ViewBag.edit = false;
                }
                ViewBag.SurveyTypeId = new SelectList(listSurveyType, "Id", "Type");
                ViewBag.UserId       = new SelectList(listUser, "Id", "Username");

                QuestionsController q = new QuestionsController();
                ViewBag.QuestionTypeId = new SelectList(q.GetQuestionType(), "Id", "Type");


                if (AccountController.CheckSurveyId())
                {
                    return(View(AccountController.GetSurvey()));
                }

                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
示例#2
0
        //------end color

        //---------------------------apply to all

        public JsonResult ApplyAll(string questionId, string color, int size)
        {
            if (AccountController.CheckSurveyId())
            {
                AnimateViewModel a;
                UpdateList();
                var id       = new Guid(questionId);
                var surveyId = AccountController.GetSurveyId();
                var q        = listQuestion.Where(x => x.SurveyId == surveyId);
                var animates = listAnimate.Where(x => x.QuestionId == id);
                if (animates != null)
                {
                    foreach (var item in q)
                    {
                        if (item.Id != id)
                        {
                            item.FontColor = color;
                            item.FontSize  = size;
                            item.UpdateQuestion(item);
                            var animates2 = listAnimate.Where(x => x.QuestionId == item.Id);

                            foreach (var i in animates)
                            {
                                var check = animates2.Where(x => x.imageType == i.imageType).FirstOrDefault();
                                if (check == null)
                                {
                                    a = new AnimateViewModel
                                    {
                                        Id         = Guid.NewGuid(),
                                        QuestionId = item.Id,
                                        ImageId    = i.ImageId,
                                        Height     = i.Height,
                                        Width      = i.Width,
                                        PosX       = i.PosX,
                                        PosY       = i.PosY,
                                        Depth      = i.Depth
                                    };
                                    a.AddAnimate();
                                }
                                else
                                {
                                    check.ImageId = i.ImageId;
                                    check.Height  = i.Height;
                                    check.Width   = i.Width;
                                    check.PosX    = i.PosX;
                                    check.PosY    = i.PosY;
                                    check.Depth   = i.Depth;
                                    check.UpdateAnimate();
                                }
                            }
                            if (animates.Count() < animates2.Count())
                            {
                                foreach (var i in animates)
                                {
                                    var check = animates2.Where(x => x.imageType != i.imageType);
                                    if (check != null)
                                    {
                                        foreach (var j in check)
                                        {
                                            j.DeleteAnimate();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(Json(questionId, JsonRequestBehavior.AllowGet));
        }