コード例 #1
0
        public ActionResult Survey(string code)
        {
            try
            {
                var surveyRepo = new SurveyRepo();
                var survey     = surveyRepo.GetById(code);
                if (survey.IsDone == true)
                {
                    TempData["Message2"] = "Bu anket zaten tamamlanmış.";
                    return(RedirectToAction("Index", "Home"));
                }
                if (survey == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                var data = Mapper.Map <Survey, SurveyVM>(survey);
                return(View(data));
            }
            catch (Exception ex)
            {
                TempData["Message2"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Survey",
                    ControllerName = "Issue",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
        }
コード例 #2
0
        public ActionResult Survey(SurveyVM model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Hata Oluştu.");
                return(RedirectToAction("Survey", "Issue", model));
            }
            try
            {
                var surveyRepo = new SurveyRepo();
                var survey     = surveyRepo.GetById(model.SurveyId);
                if (survey == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                survey.Pricing      = model.Pricing;
                survey.Satisfaction = model.Satisfaction;
                survey.Solving      = model.Solving;
                survey.Speed        = model.Speed;
                survey.TechPoint    = model.TechPoint;
                survey.Suggestions  = model.Suggestions;
                survey.IsDone       = true;
                surveyRepo.Update(survey);
                TempData["Message"] = "Anket tamamlandı.";
                return(RedirectToAction("UserProfile", "Account"));
            }
            catch (Exception ex)
            {
                TempData["Message2"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Survey",
                    ControllerName = "Issue",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
        }