示例#1
0
        public ActionResult SendFeedBack(FeedBackViewModel feedBackViewModel)
        {
            if (ModelState.IsValid)
            {
                var newFeedBack = new FeedBack();
                newFeedBack.UpdateFeedBack(feedBackViewModel);
                _feedBackSerive.Create(newFeedBack);
                _feedBackSerive.Save();

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

                string content = System.IO.File.ReadAllText(Server.MapPath("/Assets/client/templates/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    = "";
                feedBackViewModel.Email   = "";
                feedBackViewModel.Message = "";
            }
            else
            {
                MvcCaptcha.ResetCaptcha("contactCaptcha");
            }

            feedBackViewModel.ContactDetailViewModel = GetContactDetail();

            return(View("Index", feedBackViewModel));
        }
        public IActionResult Details(int id, User user)
        {
            Session session;
            EventDetailsViewModel sessionDetailsViewModel;
            FeedBackViewModel     feedBackViewModel;

            try
            {
                session = _sessionRepository.GetById(id);
                sessionDetailsViewModel = new EventDetailsViewModel
                {
                    User    = user,
                    Session = session,
                    Images  = session.Media.Where(t => t.Type == MediaType.IMAGE).ToList(),
                    Files   = session.Media.Where(t => t.Type == MediaType.FILE).ToList(),
                    Videos  = session.Media.Where(t => t.Type == MediaType.VIDEO).ToList()
                };
                feedBackViewModel = new FeedBackViewModel()
                {
                    Session = session
                };
            }
            catch (SessionNotFoundException e)
            {
                Console.Error.WriteLine(e.StackTrace);
                return(NotFound());
            }

            return(View(new Tuple <FeedBackViewModel, EventDetailsViewModel>(feedBackViewModel, sessionDetailsViewModel)));
        }
        public IActionResult AddFeedback(FeedBackViewModel feedback)
        {
            Session session;
            User    user;

            try
            {
                session = _sessionRepository.GetById(feedback.id);
                user    = _userRepository.GetById(feedback.UserId);
                session.AddFeedback(new Feedback(feedback.Score, feedback.Description, user));
                _sessionRepository.SaveChanges();
            }
            catch (SessionNotFoundException e)
            {
                Console.Error.WriteLine(e.StackTrace);
                return(NotFound());
            }
            catch (UserNotFoundException e)
            {
                Console.Error.WriteLine(e.StackTrace);
                return(NotFound());
            }

            return(RedirectToAction("Details", "Session", new { feedback.id }));
        }
示例#4
0
        public IActionResult AddAnswer(FeedBackViewModel model, string active)
        {
            ViewBag.Actice = active;

            var fb = _feedBackService.GetFeedBack(model.Id);

            string currentUserId = GetCurrentUserId();

            fb.Answer          = model.Answer;
            fb.DateTimeAnswer  = DateTime.Now;
            fb.IsAnswered      = true;
            fb.UserIdAnswering = currentUserId;

            try
            {
                _feedBackService.AddAnswer(fb);
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError(ex.Property, ex.Message);

                return(View(model));
            }

            _loggerService.LogInformation(CONTROLLER_NAME + $"/addanswer", LoggerConstants.TYPE_POST, $"add answer {model.Answer} successful", GetCurrentUserId());

            return(RedirectToAction("Index", new { active }));
        }
示例#5
0
        public IActionResult ShopFeedBack(FeedBackViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Invalid Input");
                return(Redirect("~/shop/shop-items/" + model.ShopId + "/" + model.UserId));
            }

            var user = this._context.Users.FirstOrDefault(u => u.Id == model.UserId);
            var shop = this._context.Shops.FirstOrDefault(s => s.Id == model.ShopId);


            if (user != null && shop != null)
            {
                FeedBack feedBack = new FeedBack()
                {
                    Id        = Guid.NewGuid(),
                    UserId    = model.UserId,
                    ShopId    = model.ShopId,
                    FullName  = model.FullName,
                    Comment   = model.Comment,
                    Email     = model.Email,
                    Rating    = model.Rating,
                    CreatedAt = DateTime.UtcNow,
                    UpdatedAt = DateTime.UtcNow,
                };

                this._context.FeedBacks.Add(feedBack);
                this._context.SaveChanges();
            }
            ViewBag.Success = "Message send successfully";
            return(Redirect("~/shop/shop-items/" + model.ShopId + "/" + model.UserId));
        }
示例#6
0
 public static void UpdateFeedBack(this FeedBack feedBack, FeedBackViewModel feedBackViewModel)
 {
     feedBack.Name        = feedBackViewModel.Name;
     feedBack.Email       = feedBackViewModel.Email;
     feedBack.Message     = feedBackViewModel.Message;
     feedBack.CreatedDate = DateTime.Now;
     feedBack.Status      = feedBackViewModel.Status;
 }
示例#7
0
        public ActionResult Index()
        {
            FeedBackViewModel model = new FeedBackViewModel();

            model.ContactDetailViewModel = GetContactDetail();

            return(View(model));
        }
示例#8
0
        private async void btnSure_Click(object sender, RoutedEventArgs e)
        {
            FeedBackViewModel fvm = this.DataContext as FeedBackViewModel;

            if (AppData.CanInternetAction())
            {
                if (CheckDataLegal(fvm))
                {
                    bool b = await SDKClient.SDKClient.Instance.AddFeedBack(fvm.FeedBackContent);

                    if (IsFrequentSubmission())
                    {
                        App.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            AppData.MainMV.TipMessage = "请不要频繁提交!";
                            if (!AppData.feedBackVmDic.ContainsKey(AppData.Current.LoginUser.User.ID))
                            {
                                AppData.feedBackVmDic.Add(AppData.Current.LoginUser.User.ID, fvm);
                            }
                        }));
                    }
                    else
                    {
                        if (b)
                        {
                            App.Current.Dispatcher.Invoke(new Action(() => {
                                AppData.MainMV.TipMessage = "提交成功,谢谢你的反馈!";
                                SubmitSuccess();
                                if (AppData.feedBackVmDic.ContainsKey(AppData.Current.LoginUser.User.ID))
                                {
                                    AppData.feedBackVmDic.Remove(AppData.Current.LoginUser.User.ID);
                                }
                                fvm.FeedBackContent = string.Empty;
                            }));
                        }
                        else
                        {
                            App.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                if (!AppData.feedBackVmDic.ContainsKey(AppData.Current.LoginUser.User.ID))
                                {
                                    AppData.feedBackVmDic.Add(AppData.Current.LoginUser.User.ID, fvm);
                                }
                            }));
                        }
                    }
                }
            }
            else
            {
                App.Current.Dispatcher.Invoke(new Action(() =>
                {
                    AppData.MainMV.TipMessage = "网络异常,请检查设置!";
                }));
            }
        }
示例#9
0
        public void FeedBackLink_ShouldReturnFeedBackModel()
        {
            var model = new FeedBackViewModel();

            A.CallTo(() => _feedBackBuilder.CreateFeedBackViewModel()).Returns(model);

            var result = _layoutController.FeedBack() as PartialViewResult;

            result.Model.Should().Be(model);
        }
        public void AddFeedback_UserNotFound_ReturnsNotFound()
        {
            var feedback = new FeedBackViewModel()
            {
                id = 1234, Score = 4, Description = "testet"
            };

            _mockUserRepository.Setup(u => u.GetById(feedback.UserId)).Throws(new UserNotFoundException(""));
            Assert.IsType <NotFoundResult>(_sessionController.AddFeedback(feedback));
        }
示例#11
0
        // GET: Ride/Edit/5
        public ActionResult FeedBack(int id)
        {
            var ride      = db.Rides.Where(r => r.Id == id).FirstOrDefault();
            var viewModel = new FeedBackViewModel {
                Ride     = ride,
                FeedBack = new Feedback()
            };

            return(View(viewModel));
        }
示例#12
0
        public async Task <IActionResult> AddFeedback([FromBody] FeedBackViewModel feedBack)
        {
            if (ModelState.IsValid)
            {
                var feedbackDto = _mapper.Map <FeedBackDto>(feedBack);
                await _userService.AddFeedBackForAgent(feedbackDto);

                return(Ok());
            }
            return(BadRequest());
        }
        public IHttpActionResult Post(FeedBackViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            feedBackManager.FeedBackForm(viewModel.Name, viewModel.Email, viewModel.Message);

            return(Ok(viewModel));
        }
示例#14
0
        public IHttpActionResult PostFeedback(FeedBackViewModel feedBackmodel)
        {
            ApplicationDbContext db     = new ApplicationDbContext();
            string   lastId             = db.Feedbacks.OrderByDescending(x => x.createDate).FirstOrDefault().id;
            long     index              = Convert.ToInt64(lastId.Substring(2)) + 1;
            string   feedbackId         = string.Format("IR{0}", index.ToString().PadLeft(5, '0'));
            Feedback feedBack           = null;
            var      Name1              = User.Identity.Name;
            Task <ApplicationUser> user = UserManager.FindByNameAsync(Name1);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (feedBackmodel.Attachment != null)
            {
                String ext = GetFileExtension(feedBackmodel.Attachment);
                feedBack = new Feedback {
                    id = feedbackId, title = feedBackmodel.Title, description = feedBackmodel.Description, userId = user.Result.Id, typeId = feedBackmodel.Typeid, mediumId = 11
                };
                feedBack.attachment = feedBack.id + "." + ext;
                string path = Constants.PATH + feedBack.attachment;
                if (!File.Exists(path))
                {
                    FileStream fileStream = File.Create(path);
                    fileStream.Close();
                }

                File.WriteAllBytes(path, getfile(feedBackmodel.Attachment));
            }

            else
            {
                feedBack = new Feedback {
                    id = feedbackId, title = feedBackmodel.Title, description = feedBackmodel.Description, userId = user.Result.Id, typeId = feedBackmodel.Typeid, mediumId = 11
                };
            }
            feedBack.checkStatus = Models.Constants.OPEN;
            feedInterface.Save(feedBack);
            NotificationMessage notificationMessage = new NotificationMessage();

            notificationMessage.Title      = "Ticket Raised";
            notificationMessage.Body       = feedBack.title;
            notificationMessage.For        = Constants.ROLE_HR;
            notificationMessage.Status     = feedBack.checkStatus;
            notificationMessage.FeedbackId = feedBack.id;
            eventService.notifyFeedback(notificationMessage);
            return(Ok(feedBack.id));
        }
示例#15
0
        public ActionResult FeedBackManage(int PageIndex = 1)
        {
            DealViewBag("FeedBackManage");
            FeedBackViewModel feedBackViewModel = new FeedBackViewModel
            {
                Feedbacks = EFFeedBack.Feedbacks.OrderByDescending(f => f.FeedBackID).ToPagedList(PageIndex, 10),
                PageIndex = PageIndex,
            };

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_FeedBack", feedBackViewModel));
            }
            return(View(feedBackViewModel));
        }
示例#16
0
 public ActionResult DelFeedBack(int FeedBackID, int PageIndex)
 {
     if (FeedBackID > 0)
     {
         if (EFFeedBack.DelFeedback(FeedBackID))
         {
             FeedBackViewModel feedBackViewModel = new FeedBackViewModel
             {
                 Feedbacks = EFFeedBack.Feedbacks.OrderByDescending(f => f.FeedBackID).ToPagedList(PageIndex, 10),
                 PageIndex = PageIndex,
             };
             return(PartialView("_FeedBack", feedBackViewModel));
         }
     }
     return(View(false));
 }
示例#17
0
        public FeedBackViewModel GetById(int?id)
        {
            FeedBackViewModel dr = new FeedBackViewModel();

            using (var obj = new FeedBackRepository())
            {
                if (id != null)
                {
                    var _obj = obj.GetById(id.Value);

                    dr.PatientId = _obj.PatientId;
                }

                return(dr);
            }
        }
示例#18
0
        public ActionResult Index(FeedBackViewModel feedBack)
        {
            if (ModelState.IsValid)
            {
                _service.CreateFeedback(feedBack.NewFeedBack);
                return(RedirectToAction("Index"));
            }
            var items = _service.GetFeedbackItems();

            if (items != null && items.Any())
            {
                feedBack.FeedBacks = _service.GetFeedbackItems();
                return(View(feedBack));
            }
            return(HttpNotFound());
        }
示例#19
0
 public void CreateMethod(FeedBackViewModel model, string feedback)
 {
     using (var obj = new FeedBackRepository())
         if (model.PatientId == 0)
         {
             FeedBack _fd = new FeedBack
             {
                 PatientId = model.PatientId,
                 Name      = model.Name,
                 Email     = model.Email,
                 Comment   = model.Comment,
                 Votes     = feedback
             };
             obj.Insert(_fd);
         }
 }
        public void AddFeedback_SessionFound_AddsFeedbacktoSession()
        {
            var feedback = new FeedBackViewModel()
            {
                id = 1, Score = 4, Description = "testet"
            };

            _mockSessionRepository.Setup(s => s.GetById(feedback.id)).Returns(_dummyContext.Sessions.First(s => s.SessionId == feedback.id));
            var result = Assert.IsType <RedirectToActionResult>(_sessionController.AddFeedback(feedback));

            Assert.Equal("Details", result?.ActionName);
            Session session = _dummyContext.Sessions.First(s => s.SessionId == feedback.id);

            session.Feedback.Any(fb => fb.Description == feedback.Description && fb.Score == feedback.Score);
            _mockSessionRepository.Verify(m => m.SaveChanges(), Times.Once);
        }
示例#21
0
        public ActionResult Index()
        {
            var items = _service.GetFeedbackItems();

            if (items != null && items.Any())
            {
                FeedBackViewModel feedBackViewModel = new FeedBackViewModel
                {
                    FeedBacks   = items,
                    NewFeedBack = new FeedBack()
                };
                return(View(feedBackViewModel));
            }

            return(HttpNotFound());
        }
 public ActionResult DelFeedBack(int FeedBackID)
 {
     if (FeedBackID > 0)
     {
         if (EFFeedBack.DelFeedback(FeedBackID))
         {
             FeedBackViewModel feedBackViewModel = new FeedBackViewModel
             {
                 PageIndex = 1,
                 Feedbacks = EFPerson.Feedbacks(UserID).ToPagedList(1, 10)
             };
             return(PartialView("_FeedBack", feedBackViewModel));
         }
     }
     return(View(false));
 }
示例#23
0
        public FeedBackViewModel DetailsMethod(int?id)
        {
            FeedBackViewModel dr = new FeedBackViewModel();

            using (var fd = new FeedBackRepository())
            {
                if (id.HasValue && id != 0)
                {
                    FeedBack _fb = fd.GetById(id.Value);

                    dr.PatientId = _fb.PatientId;
                    dr.Name      = _fb.Name;
                    dr.Email     = _fb.Email;
                    dr.Comment   = _fb.Comment;
                }
                return(dr);
            }
        }
示例#24
0
        public FeedBackViewModel GetDeleteMethod(int id)
        {
            FeedBackViewModel rm = new FeedBackViewModel();

            using (var parepo = new FeedBackRepository())
            {
                if (id != 0)
                {
                    FeedBack _patient = parepo.GetById(id);

                    rm.PatientId = _patient.PatientId;
                    rm.Name      = _patient.Name;
                    rm.Email     = _patient.Email;
                    rm.Comment   = _patient.Comment;
                }

                return(rm);
            }
        }
示例#25
0
        public IHttpActionResult updateTicketbyUser(string Id, FeedBackViewModel feedBackmodel)
        {
            Feedback f = db.Feedbacks.Find(Id);

            if (f == null)
            {
                return(BadRequest(" Ticket id not found"));
            }

            else
            {
                f.checkStatus     = Models.Constants.OPEN;
                f.status          = Models.Constants.OPEN;
                f.description     = feedBackmodel.Description;
                db.Entry(f).State = EntityState.Modified;
                db.SaveChanges();
                return(Ok());
            }
        }
示例#26
0
 private bool CheckDataLegal(FeedBackViewModel fvm)
 {
     if (!string.IsNullOrEmpty(fvm.FeedBackContent))
     {
         int contentLegth = fvm.FeedBackContent.Replace(" ", "").Length;
         if (contentLegth < 5)
         {
             App.Current.Dispatcher.Invoke(new Action(() => {
                 AppData.MainMV.TipMessage = "内容过短!";
             }));
             return(false);
         }
         return(true);
     }
     else
     {
         this.btnSure.IsEnabled = false;
         return(false);
     }
 }
示例#27
0
 public ActionResult AddReply(int FeedBackID, string Reply, int PageIndex)
 {
     if (FeedBackID > 0 && !string.IsNullOrEmpty(Reply))
     {
         Feedback feedback = EFFeedBack.Feedback(FeedBackID);
         if (feedback != null)
         {
             feedback.Reply = Reply;
             if (EFFeedBack.UpdateFeedback(feedback))
             {
                 FeedBackViewModel feedBackViewModel = new FeedBackViewModel
                 {
                     Feedbacks = EFFeedBack.Feedbacks.OrderByDescending(f => f.FeedBackID).ToPagedList(PageIndex, 10),
                     PageIndex = PageIndex,
                 };
                 return(PartialView("_FeedBack", feedBackViewModel));
             }
         }
     }
     return(View(false));
 }
示例#28
0
        public IHttpActionResult PostFeedback(FeedBackViewModel feedBackmodel)
        {
            Feedback feedBack           = null;
            var      Name1              = User.Identity.Name;
            Task <ApplicationUser> user = UserManager.FindByNameAsync(Name1);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (feedBackmodel.Attachment != null)
            {
                String ext = GetFileExtension(feedBackmodel.Attachment);
                feedBack = new Feedback {
                    title = feedBackmodel.Title, description = feedBackmodel.Description, userId = user.Result.Id, typeId = feedBackmodel.Typeid, mediumId = 11
                };
                feedBack.attachment = feedBack.id + "." + ext;
                string path = Constants.PATH + feedBack.attachment;
                if (!File.Exists(path))
                {
                    FileStream fileStream = File.Create(path);
                    fileStream.Close();
                }

                File.WriteAllBytes(path, getfile(feedBackmodel.Attachment));
            }

            else
            {
                feedBack = new Feedback {
                    title = feedBackmodel.Title, description = feedBackmodel.Description, userId = user.Result.Id, typeId = feedBackmodel.Typeid, mediumId = 11
                };
            }
            feedBack.checkStatus = Models.Constants.OPEN;
            feedInterface.Save(feedBack);
            eventService.notifyFeedback(feedBack);
            return(Ok(feedBack.id));
        }
示例#29
0
        public ActionResult Contact(FeedBackViewModel model)
        {
            var db          = Globals.GetDatabase();
            var newFeedBack = new FeedBack();

            newFeedBack.FeedBackName  = model.FeedBackName;
            newFeedBack.FeedBackEmail = model.FeedBackEmail;
            newFeedBack.FeedBackDesc  = model.FeedBackDesc;
            if (newFeedBack.FeedBackName != null && newFeedBack.FeedBackEmail != null && newFeedBack.FeedBackDesc != null)
            {
                string      emailFrom = "*****@*****.**";
                string      password  = "******";
                string      emailTo   = "*****@*****.**";
                string      subject   = "Feedback from " + newFeedBack.FeedBackName + " having email " + newFeedBack.FeedBackEmail;
                string      body      = newFeedBack.FeedBackDesc;
                MailMessage mail      = new MailMessage();
                mail.From = new MailAddress(emailFrom);
                mail.To.Add(emailTo);

                mail.Subject    = subject;
                mail.Body       = body;
                mail.IsBodyHtml = false;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = new System.Net.NetworkCredential(emailFrom, password);
                smtp.EnableSsl             = true;
                smtp.Send(mail);

                db.Feedbacks.Add(newFeedBack);
                db.SaveChanges();
            }
            else
            {
                ModelState.AddModelError("NewFeedBack", "Please Enter All The Details");
            }
            return(View());
        }
        public ActionResult FeedBack(int PageIndex = 1, string keyword = null)
        {
            DealViewBag("FeedBack");
            FeedBackViewModel feedBackViewModel = new FeedBackViewModel
            {
                PageIndex = PageIndex,
            };

            if (!string.IsNullOrEmpty(keyword))
            {
                feedBackViewModel.Feedbacks = EFPerson.Feedbacks(UserID).Where(f => f.Title.ToString().Contains(keyword) || f.Context.ToString().Contains(keyword)).ToPagedList(PageIndex, 10);
            }
            else
            {
                feedBackViewModel.Feedbacks = EFPerson.Feedbacks(UserID).ToPagedList(PageIndex, 10);
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_FeedBack", feedBackViewModel));
            }
            return(View(feedBackViewModel));
        }