Exemplo n.º 1
0
        public HttpResponseMessage Create(HttpRequestMessage request, FeedbackViewModel feedbackViewModel)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    //trả về lỗi để bên ngoài bắt được sự kiện lỗi này
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var newfeedbacks = new Feedback();
                    newfeedbacks.UpdateFeedback(feedbackViewModel);
                    newfeedbacks.CreateDate = DateTime.Now;
                    newfeedbacks.Status = false;

                    _feedbackService.Create(newfeedbacks);
                    _feedbackService.Save();

                    var responseData = Mapper.Map <Feedback, FeedbackViewModel>(newfeedbacks);
                    response = request.CreateResponse(HttpStatusCode.Created, responseData);
                }

                return response;
            }));
        }
Exemplo n.º 2
0
        public ActionResult Feedback(FeedbackViewModel feedbackViewModel)
        {
            int    courseId = _coursesContentService.GetCourseId(Umbraco.AssignedContentItem);
            string username = User.Identity.Name;

            if (!_subscriptionsService.HasActiveSubscription(username, courseId))
            {
                return(Redirect(Umbraco.AssignedContentItem.Url));
            }

            if (!_feedbackService.UserHasSentFeedback(username, courseId))
            {
                FeedbackViewModel feedbackViewModelTemplate = GetFeedbackViewModel();
                MergeFeedbackModels(feedbackViewModel, feedbackViewModelTemplate);

                if (!ModelState.IsValid)
                {
                    return(View(feedbackViewModel));
                }

                User     user     = _userService.GetByUsername(username);
                Feedback feedback = new Feedback
                {
                    CourseId        = courseId,
                    UserId          = user.Id,
                    Submission      = JsonConvert.SerializeObject(feedbackViewModel.Questions),
                    AdditionalNotes = feedbackViewModel.AdditionalNotes
                };

                _feedbackService.Create(feedback);
            }

            return(RedirectToRoute("Assessment", new { courseNiceUrl = Umbraco.AssignedContentItem.UrlName }));
        }
Exemplo n.º 3
0
        public ActionResult SendFeedback(FeedbackViewModel feedbackViewModel)
        {
            if (ModelState.IsValid)
            {
                var newFeedback = new Feedback();

                newFeedback.UpdateFeedback(feedbackViewModel);

                _feedbackService.Create(newFeedback);
                _feedbackService.Save();

                TempData["MessageSuccess"] = "Gửi phản hổi thành công";

                string content = System.IO.File.ReadAllText(Server.MapPath("/Assets/client/template/contact_template.html"));
                content = content.Replace("{{Name}}", feedbackViewModel.Name);
                content = content.Replace("{{Email}}", feedbackViewModel.Email);
                content = content.Replace("{{Message}}", feedbackViewModel.Message);
                var adminEmail = ConfigHelper.GetByKey("AdminEmail");
                MailHelper.SendMail(adminEmail, "Thông tin liên hệ từ website", content);

                feedbackViewModel.Name    = string.Empty;
                feedbackViewModel.Email   = string.Empty;
                feedbackViewModel.Message = string.Empty;
            }

            feedbackViewModel.ContactDetail = GetDetail();

            return(View("Index", feedbackViewModel));
        }
Exemplo n.º 4
0
        public ActionResult SendFeedback(FeedbackViewModel feedbackViewModel)
        {
            if (ModelState.IsValid)
            {
                Feedback newFeedback = new Feedback();
                newFeedback.UpdateFeedback(feedbackViewModel);
                _feedbackService.Create(newFeedback);
                _feedbackService.Save();
                ViewData["SuccessMsg"] = "Send Feedback Seccess!";



                //StringBuilder builder = new StringBuilder();
                //builder.Append("Infomation contact !");
                // MapPath:lấy vị trí tuyết đối
                string content = System.IO.File.ReadAllText(Server.MapPath("/Assets/client/template/contact_template.html"));
                content = content.Replace("{{Name}}", feedbackViewModel.Name);
                content = content.Replace("{{Email}}", feedbackViewModel.Email);
                content = content.Replace("{{Message}}", feedbackViewModel.Message);

                var adminEmail = ConfigHelper.GetByKey("AdminEmail");
                MailHelper.SendMail(adminEmail, "Infomation from website", content);
            }
            feedbackViewModel.ContactDetail = GetDetail();
            feedbackViewModel.Name          = "";
            feedbackViewModel.Message       = "";
            feedbackViewModel.Email         = "";
            return(View("Index", feedbackViewModel));
        }
        public ActionResult SendFeedback(FeedbackViewModel feedbackViewModel)
        {
            if (ModelState.IsValid)
            {
                Feedback newFeedback = new Feedback();
                newFeedback.CoppyDataFeedback(feedbackViewModel);
                _feedbackService.Create(newFeedback);
                _feedbackService.SaveChanges();

                ViewData["SuccessMsg"] = "Phản hồi đã được gởi đi";

                string content = System.IO.File.ReadAllText(Server.MapPath("~/Assets/Client/template/contact_template.html"));
                content = content.Replace("{{Name}}", feedbackViewModel.Name);
                content = content.Replace("{{Email}}", feedbackViewModel.Email);
                content = content.Replace("{{Message}}", feedbackViewModel.Message);
                var emailAdmin = ConfigHelper.GetByKey("EmailAdmin");
                MailHelper.SendMail(emailAdmin, "Thông tin liên hệ từ website", content);
                MailHelper.SendMail(feedbackViewModel.Email, "Thông tin phản hồi từ website", content);

                feedbackViewModel.Name    = string.Empty;
                feedbackViewModel.Email   = string.Empty;
                feedbackViewModel.Message = string.Empty;
            }
            feedbackViewModel.ContactDetail = GetDetail();
            return(View("Index", feedbackViewModel));
        }
Exemplo n.º 6
0
        public ActionResult SendFeedback(FeedbackViewModel feedbackVM)
        {
            if (ModelState.IsValid)
            {
                var feedback = Mapper.Map <Feedback>(feedbackVM);
                feedback.CreatedDate = DateTime.Now;
                _feedbackService.Create(feedback);
                _feedbackService.Save();

                ViewData[Constant.ViewData_SuccessMsg] = ResourceManagement.GetResourceText(Constant.Resource_SendFeedbackSuccess);

                string content = System.IO.File.ReadAllText(Server.MapPath(Constant.Path_ContactTemplate));
                content = content.Replace("{{Name}}", feedbackVM.Name);
                content = content.Replace("{{Email}}", feedbackVM.Email);
                content = content.Replace("{{Message}}", feedbackVM.Message);
                var adminEmail = ConfigHelperUtility.GetByKey(Constant.AppSetting_AdminEmail);
                MailHelperUtility.SendMail(adminEmail, ResourceManagement.GetResourceText(Constant.Resource_ContactInformationFromWebsite), content);

                feedbackVM.Name    = string.Empty;
                feedbackVM.Message = string.Empty;
                feedbackVM.Email   = string.Empty;
            }
            feedbackVM.ContactDetail = GetDetail();

            return(View(Constant.Action_Index, feedbackVM));
        }
Exemplo n.º 7
0
        public ActionResult SendFeedback(FeedbackViewModel feedbackVm)
        {
            if (ModelState.IsValid)
            {
                var feedback = new Feedback();
                feedback.UpdateFeedback(feedbackVm);
                feedback.Status = true;
                _feedbackService.Create(feedback);
                _feedbackService.Save();

                ViewData["SuccessMsg"] = "Gửi phản hồi thành công";

                string content = System.IO.File.ReadAllText(Server.MapPath("/assets/client/template/contact_template.html"));
                content = content.Replace("{{Name}}", feedbackVm.Name);
                content = content.Replace("{{Email}}", feedbackVm.Email);
                content = content.Replace("{{Message}}", feedbackVm.Message);
                var adminEmail = ConfigHelper.GetByKey("AdminEmail");
                MailHelper.SendMail(adminEmail, "Thông tin liên hệ từ website", content);

                ModelState["Name"].Value    = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                ModelState["Email"].Value   = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                ModelState["Message"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
            }
            feedbackVm.ContactDetail = GetDetail();
            return(View("Index", feedbackVm));
        }
Exemplo n.º 8
0
        public ActionResult SendFeedback(FeedbackViewModel feedbackVm)
        {
            if (ModelState.IsValid)
            {
                Feedback newFeedback = new Feedback();
                newFeedback.UpdateFeedback(feedbackVm);
                _feedbackService.Create(newFeedback);
                _feedbackService.Save();

                ViewData["SuccessMsg"] = "Gửi phản hồi thành công!";

                // send response mail
                string mailContent = System.IO.File.ReadAllText(Server.MapPath("/Assets/client/template/contactMailResponse.html"));
                mailContent = mailContent.Replace("{{Name}}", feedbackVm.Name);
                mailContent = mailContent.Replace("{{Email}}", feedbackVm.Email);
                mailContent = mailContent.Replace("{{Message}}", feedbackVm.Message);

                //var adminEmail = ConfigHelper.GetByKey("AdminEmail");
                var toEmail = feedbackVm.Email;

                string mailSubject = "Trả lời phản hồi khách hàng:";
                MailHelper.SendMail(toEmail, mailSubject, mailContent);
            }
            //Reset infor in form after submit
            //ModelState.Clear();

            feedbackVm.ContactDetail = getContactDetail();
            return(View("Index", feedbackVm));
        }
Exemplo n.º 9
0
#pragma warning disable S4261 // Methods should be named according to their synchronicities
        public async Task <JsonResult> Create(FeedbackViewModel feedbackViewModel)
#pragma warning restore S4261 // Methods should be named according to their synchronicities
        {
            var result = new FeedbackMessageViewModel {
                ResultMessage       = Resources.UI.TournamentController.CheckCaptcha,
                OperationSuccessful = false
            };

            try
            {
                var isCaptchaValid = await _captchaManager.ValidateUserCaptchaAsync(feedbackViewModel.CaptchaResponse);

                if (isCaptchaValid)
                {
                    if (ModelState.IsValid)
                    {
                        var domainFeedback = feedbackViewModel.ToDomain();
                        _feedbackService.Create(domainFeedback);
                        result.ResultMessage       = Resources.UI.TournamentController.SuccessfulSent;
                        result.OperationSuccessful = true;
                    }
                    else
                    {
                        result.ResultMessage = Resources.UI.TournamentController.CheckData;
                    }
                }
            }
            catch (ArgumentException ex)
            {
                ModelState.AddModelError("ValidationMessage", ex.Message);
            }

            return(Json(result, JsonRequestBehavior.DenyGet));
        }
Exemplo n.º 10
0
        public ActionResult SendResult(FeedbackModel feedbackModel)
        {
            if (ModelState.IsValid)
            {
                Feedback feedback = new Feedback();
                feedback.UpdateFeedBack(feedbackModel);
                _feedbackService.Create(feedback);
                _feedbackService.Save();

                ViewData["SuccessMsg"] = "Gửi phản hồi thành công.";

                string content = System.IO.File.ReadAllText(Server.MapPath("/Assets/Client/template/contact_template.html"));
                content = content.Replace("{{Name}}", feedbackModel.Name);
                content = content.Replace("{{Email}}", feedbackModel.Email);
                content = content.Replace("{{Message}}", feedbackModel.Message);
                var adminEmail = ConfigHelper.GetByKey("AdminEmail");
                MailHelper.SendMail(adminEmail, "Thông tin liên hệ từ website", content);


                feedbackModel.Name    = "";
                feedbackModel.Message = "";
                feedbackModel.Email   = "";
            }
            feedbackModel.ThongTinLienLacModel = GetDetail();

            return(View("Index", feedbackModel));
        }
Exemplo n.º 11
0
 public IActionResult Add(FeedbackDTO dto)
 {
     if (ModelState.IsValid)
     {
         _feedbackService.Create(dto);
     }
     return(Ok());
 }
Exemplo n.º 12
0
 public ActionResult Create(FeedbackViewModel feedback)
 {
     if (ModelState.IsValid)
     {
         var carrierId = Url.RequestContext.RouteData.Values["id"];
         feedback.CarrierId = Convert.ToInt32(carrierId);
         feedback.Date      = DateTime.Now;
         _feedbackService.Create(Mapper.Map <FeedbackDTO>(feedback));
     }
     return(RedirectToAction("CarrierFeedbacks", "Feedback", feedback));
 }
Exemplo n.º 13
0
        public IActionResult Add(FeedbackDTO dto)
        {
            if (!IsValidAuthenticationRole("Patient"))
            {
                return(StatusCode(403));
            }

            try
            {
                Guid id = _feedbackService.Create(dto);
                return(Created("/api/feedback", id));
            }catch (FeedbackCommentEmptyException)
            {
                return(BadRequest());
            }catch (Exception)
            {
                return(StatusCode(500));
            }
        }
Exemplo n.º 14
0
        //  [CaptchaValidation("CaptchaCode", "contactCaptcha", "Mã xác nhận không đúng")]
        public ActionResult SendFeedback(FeedbackViewModel feedbackViewModel)
        {
            if (ModelState.IsValid)
            {
                Feedback newFeedback = new Feedback();
                newFeedback.UpdateFeedback(feedbackViewModel);
                _feedbackService.Create(newFeedback);
                _feedbackService.Save();

                ViewData["SuccessMsg"] = "Gửi phản hồi thành công";

                string content = System.IO.File.ReadAllText(Server.MapPath("/Assets/client/mail/contact_mail.html"));
                content = content.Replace("{{Name}}", feedbackViewModel.Name);
                content = content.Replace("{{Email}}", feedbackViewModel.Email);
                content = content.Replace("{{Message}}", feedbackViewModel.Message);
                string adminEmail = "*****@*****.**";
                MailHelper.SendMail(adminEmail, "Thông tin liên hệ từ Legend Never Die", content);
            }
            feedbackViewModel.ContactDetail = GetDetail();

            return(View("Index", feedbackViewModel));
        }
Exemplo n.º 15
0
        public HttpResponseMessage Create(FeedbackDto feedbackDto)
        {
            var feedback = Mapper.Map <FeedbackDto, Feedback>(feedbackDto);
            var success  = true;
            var message  = "Gửi feedback thành công";

            try
            {
                _feedbackService.Create(feedback);
            } catch (Exception ex)
            {
                success = false;
                message = ex.Message + "\n" + ex.StackTrace;
            }
            var result = new
            {
                Success = success,
                Message = message
            };
            var response = Request.CreateResponse(HttpStatusCode.OK, result);

            return(response);
        }
Exemplo n.º 16
0
        [SimpleCaptchaValidation("CaptchaCode", "contactCaptcha", "Mã xác nhận không đúng!")] // adđ sử dụng capcha(botdetect- Nugetpacket) https://captcha.com/asp.net-captcha.html
        public ActionResult SendFeedback(FeedbackViewModel feedbackViewModel)
        {
            if (ModelState.IsValid)
            {
                Feedback feedback = new Feedback();
                feedback.UpdateFeedback(feedbackViewModel);
                _feedbackService.Create(feedback);
                _feedbackService.Save();

                ViewData["ThanhCong"] = "gửi phải hồi thành công";

                // đọc template mail ,ghi thông tin và gửi về website
                string content = System.IO.File.ReadAllText(Server.MapPath("~/Assets/client/template/ContactTemplate.html"));
                content = content.Replace("{{Name}}", feedbackViewModel.Name);
                content = content.Replace("{{Email}}", feedbackViewModel.Email);
                content = content.Replace("{{Message}}", feedbackViewModel.Message);
                // gửi mail về cho mail admin, cấu hình trong appsetting
                var adminEmail = ConfigHelper.GetByKey("AdminEmail");
                MailHelper.SendMail(adminEmail, "Thông tin liên hệ từ website", content);

                // sau khi phải hồi được gửi lên server => trả về input rỗng
                feedbackViewModel.Name    = string.Empty;
                feedbackViewModel.Email   = string.Empty;
                feedbackViewModel.Message = string.Empty;
            }
            else
            {
                MvcCaptcha.ResetCaptcha("contactCaptcha");
            }
            feedbackViewModel.ContactDetail = GetDetail();



            // đẩy tiếp feedbackviewmodel vào index
            return(View("Index", feedbackViewModel));
        }
Exemplo n.º 17
0
 public IActionResult CreateFeedback([FromBody] FeedbackRequestDto dto)
 {
     return(Created("", feedbackService.Create(dto)));
 }
Exemplo n.º 18
0
 public void Feedback(FeedbackCreateRequestDTO request)
 {
     _service.Create(request);
 }
 public async Task <ActionResult <FeedbackUser> > Post([FromBody] FeedbackUser feedback)
 {
     return(await _feedback.Create(feedback));
 }