Exemplo n.º 1
0
 public IActionResult Index(Feedback feedback)
 {
     if (ModelState.IsValid)
     {
         _feedbackRepository.AddFeedback(feedback);
         return(RedirectToAction("FeedbackComplete"));
     }
     return(View(feedback));
 }
Exemplo n.º 2
0
 public IActionResult Index(Feedback feedback)
 {
     //feedback instance is going to be created using model binding
     if (ModelState.IsValid)
     {
         _feedbackRepository.AddFeedback(feedback);
         return(RedirectToAction("FeedbackComplete"));
     }
     return(View(feedback));
 }
 public IActionResult Index(Feedback feedback)
 {
     // Add modelstate to validate the validation property for the feedback entry
     if (ModelState.IsValid)
     {
         _feedbackRepository.AddFeedback(feedback);
         return(RedirectToAction("FeedbackComplete"));
     }
     return(View(feedback));
 }
Exemplo n.º 4
0
 public IActionResult Index(Feedback feedback)
 {
     if (ModelState.IsValid)
     {
         feedback.CreateDateUTC = Microsoft.VisualBasic.DateAndTime.Now;
         _feedbackRepository.AddFeedback(feedback);
         return(RedirectToAction("FeedbackComplete"));
     }
     return(View());
 }
Exemplo n.º 5
0
        public IActionResult Feedback(Feedback feedbackModel)
        {
            if (ModelState.IsValid)
            {
                _feedbackRepository.AddFeedback(feedbackModel);
                return(RedirectToAction("Index", "Home"));
            }

            return(View(feedbackModel));
        }
Exemplo n.º 6
0
        public IActionResult Index(Feedback feedback)
        {
            if (ModelState.IsValid)
            {
                _feedbackRepository.AddFeedback(feedback);
                return(RedirectToAction("FeedbackComplete"));
            }

            //return same data to the user, with the form already filled
            return(View(feedback));
        }
Exemplo n.º 7
0
 public IActionResult Index(Feedback feedback)
 {
     //Tag helper
     if (ModelState.IsValid)
     {
         //把新的评价加入到仓库里
         _feedbackRepository.AddFeedback(feedback);
         return(RedirectToAction("FeedbackComplete"));
     }
     return(View());//返回用户评价输入页面,并且提示失败信息
 }
        public IActionResult Index(Feedback feedback)
        {
            // to validate the model passed through the form
            if (ModelState.IsValid)
            {
                _feedbackRepository.AddFeedback(feedback);
                return(RedirectToAction("FeedBackComplete"));
            }

            return(View(feedback));
        }
 public IActionResult Index(Feedback feedback)
 {
     // if user enetrs data this feedback instance is going o be sent to the controller
     // then pass it on to the repository
     //redirect user to another action FeedbackComplete method to thank him for the feedback
     if (ModelState.IsValid)
     {
         _feedbackRepository.AddFeedback(feedback);
         return(RedirectToAction("FeedbackComplete"));
     }
     return(View(feedback));
 }
Exemplo n.º 10
0
 public IActionResult Index(Feedback feedback)
 {
     //50.启动数据验证->Feedback/Index.cshtml显示错误提示信息
     if (ModelState.IsValid)
     {
         //44.调用添加函数
         _feedbackRepository.AddFeedback(feedback);
         //45.定向到评价完成页面
         return(RedirectToAction("FeedbackComplete"));
     }
     return(View());//若验证不成功则继续留在上传页面Views/Index.cshtml
 }
Exemplo n.º 11
0
        public ActionResult <Feedback> Feedback(Feedback feedback)
        {
            if (ModelState.IsValid)
            {
                _feedbackRepository.AddFeedback(feedback);

                return(Ok(_feedbackRepository.Get()));
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 12
0
        public IActionResult Index(FeedbackDto feedbackDto)
        {
            if (ModelState.IsValid)
            {
                var feedback = _mapper.Map <Feedback>(feedbackDto);

                _repository.AddFeedback(feedback);

                return(RedirectToAction("FeedbackComplete"));
            }

            return(View(feedbackDto));
        }
        public async Task <IActionResult> Index(Feedback feedback)
        {
            if (!ModelState.IsValid)
            {
                //test
                //ModelState.AddModelError("Name", "this is a validation error from the server!");
                return(View(feedback));
            }

            await _feedbackRepository.AddFeedback(Map(feedback));

            return(RedirectToAction("FeedbackComplete"));
        }
Exemplo n.º 14
0
 //takes the feedback parameter
 public IActionResult Index(Feedback feedback)
 {
     {
         //checks of model state or entered data is valid through model binding
         if (ModelState.IsValid)
         {
             //add feedback to the database
             _feedbackRepository.AddFeedback(feedback);
             //return to the FeedbackComplete view
             return(RedirectToAction("FeedbackComplete"));
         }
         return(View(feedback));
     }
 }
Exemplo n.º 15
0
 public IActionResult Index(Feedback feedback)
 {
     //If there are no errors in the ModelState (is valid), add feedback data and display confirm message
     if (ModelState.IsValid)
     {
         _feedbackRepository.AddFeedback(feedback);
         //Redirect user to another action method to display 'Thanks for Feedback'
         return(RedirectToAction("FeedbackComplete"));
     }
     else
     {
         //If errors exist in ModelState then return user to same page with the same data.
         return(View(feedback));
     }
 }
Exemplo n.º 16
0
        /* This method was written by Bob van Beek (610685) */
        /// <summary>
        /// Asynchronous method that add a Feedback record to the context.
        /// </summary>
        /// <param name="feedback"></param>
        /// <returns>Filled Feedback class or null</returns>
        public async Task <Feedback> AddFeedback(Feedback feedback)
        {
            try
            {
                _logger.Information($"A request has been made to add a Feedback record with id {feedback.Id} to the context.");
                feedback.Id = Guid.NewGuid();
                Feedback f = await _feedbackRepo.AddFeedback(feedback);

                return(feedback ?? throw new Exception($"Dependency failure: The repository returned null."));
            }
            catch (Exception e) // Error handling
            {
                _logger.Error($"IFeedbackService says: {e.Message} Exception occured on line {new StackTrace(e, true).GetFrame(0).GetFileLineNumber()}.");
                return(null);
            }
        }
Exemplo n.º 17
0
 public IActionResult CreateFeedback(FeedbackVM model)
 {
     if (ModelState.IsValid)
     {
         var      userId   = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         Feedback feedback = new Feedback
         {
             Comment    = model.Comment,
             Rating     = model.Rating,
             OutfitId   = model.OutfitId,
             CustomerId = userId,
             Date       = DateTime.Now
         };
         feedbackRepository.AddFeedback(feedback);
     }
     return(RedirectToAction("Details", "Home", new { model.OutfitId }));
 }
        public async Task <ActionResult <Feedback> > AddFeedback(FeedbackPostRequest data)
        {
            var user = await _userRepository.GetUserByTokenId(data.TokenId);

            if (user == null)
            {
                return(Unauthorized());
            }

            var result = await _repository.AddFeedback(data.Anonymus?null : user.Id, data.Title, user.CourseId, user.City);

            if (result >= 0)
            {
                return(Created("New feedback added", result));
            }

            return(BadRequest());
        }
Exemplo n.º 19
0
        public IActionResult Post(string feedback)
        {
            var status  = false;
            var message = string.Empty;

            try
            {
                var data = JsonConvert.DeserializeObject <Feedback>(feedback);
                data.CreatedDate = DateTime.Now;
                _feedbackRepository.AddFeedback(data);
                _feedbackRepository.SaveChange();
                status = true;
            }
            catch (Exception)
            {
                message = "";
            }
            return(Json(new
            {
                status = status
            }));
        }
Exemplo n.º 20
0
 public IActionResult Index(Feedback feedback)
 {
     _feedbackRepository.AddFeedback(feedback);
     return(RedirectToAction("FeedbackComplete"));
 }
Exemplo n.º 21
0
 public void AddFeedback(Feedback feedback)
 {
     feedback.CreatedDate = DateTime.Now;
     _feedbackRepository.AddFeedback(feedback);
 }
Exemplo n.º 22
0
        //public string AddFeedback()
        //{
        //    SubjectDto subjectDto = new SubjectDto(1467,"Subject");
        //    ClassDto classDto = new ClassDto(){ Id = 1839, Subject = subjectDto, ClassType=ClassTypeEnum.C};
        //    ActualClassDto actualClassDto = new ActualClassDto() { Id = 1 ,Date = DateTime.Today, Class = classDto };
        //    FeedbackDto fb = new FeedbackDto() { Attractiveness = 3, Clearness = 3, Comprehension = 5,  Correctness = 3, HighScientificLevel = 3, Interactivity = 3, Novelty = 3, RigorousScientificLevel = 3, Usefulness = 3, ActualClass = actualClassDto};

        //    JavaScriptSerializer sr = new JavaScriptSerializer();
        //    string message= sr.Serialize(fb);

        //    return message;
        //}

        public int Add(FeedbackDto fb)
        {
            return(_feedbackRepository.AddFeedback(fb));
        }
Exemplo n.º 23
0
 public IActionResult Index(Feedback feedback)
 {
     _feedbackRepository.AddFeedback(feedback);
     return(View());
     //return RedirectToAction("FeedbackReceived");
 }
Exemplo n.º 24
0
 public void AddFeedback(Feedback feedback)
 {
     _feedbackRepository.AddFeedback(feedback);
     _isSaved = _feedbackRepository.IsSuccess();
 }
Exemplo n.º 25
0
 public void AddFeedback(FeedbackDto feedbackDto)
 {
     _feedbackRepository.AddFeedback(_mapper.Map <FeedbackDto, Feedback>(feedbackDto));
 }