示例#1
0
        public async Task <FeedbackVM> CreateFeedbackAsync(CreateFeedbackVM f)
        {
            var dbFeedback = new Feedback
            {
                Stars         = f.Stars,
                Comment       = f.Comment,
                UserProfileId = f.UserProfileId
            };

            if (f.LocationId != null)
            {
                dbFeedback.LocationId = f.LocationId;
            }
            if (f.MenuItemId != null)
            {
                dbFeedback.MenuItemId = f.MenuItemId;
            }

            var newFeedback = await _db.Feedbacks.CreateAsync(dbFeedback);

            var f2 = _db.Feedbacks.GetAll().FirstOrDefault(m => m.Id == newFeedback.Id);

            if (f2 != null)
            {
                var retFeedback = new FeedbackVM(f2, f2.UserProfile, f2.Photos);
                if (f.UploadPhoto != null)
                {
                    await _fileService.CreateFileDbAsync(f.UploadPhoto, retFeedback.Id);
                }
                return(retFeedback);
            }
            throw new Exception("feedback not found");
        }
示例#2
0
        public IActionResult Upsert(FeedbackVM form)
        {
            var claimsIdentity = (ClaimsIdentity)User.Identity;
            var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);

            var user = _unitOfWork.User.GetFirstOrDefault(c => c.Id == claim.Value);

            var formvm = new Feedback
            {
                ApplicationUserId = user.Id,
                Comment           = form.Comment
            };

            if (ModelState.IsValid)
            {
                if (form.Id == 0)
                {
                    _db.Feedbacks.Add(formvm);
                }
                else
                {
                    _db.Feedbacks.Update(formvm);
                }
                _unitOfWork.Save();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(form));
        }
示例#3
0
        public async Task <IEnumerable <FeedbackVM> > GetFeedbackQuestionsByParticipantType(PostFeedback postFeedback)
        {
            List <FeedbackVM> allQuestions = new List <FeedbackVM>();

            var fbAllQuestions = await _fbQuestionRepository.GetAll();

            var participantQns = fbAllQuestions.Where(x => x.ParticipantType == postFeedback.ParticipantType).ToList();

            foreach (var fbQuestion in participantQns)
            {
                FeedbackVM feedbackVM = new FeedbackVM();
                feedbackVM.Id              = fbQuestion.Id;
                feedbackVM.Question        = fbQuestion.Question;
                feedbackVM.ParticipantType = fbQuestion.ParticipantType;
                feedbackVM.QuestionTye     = fbQuestion.QuestionTye;

                var questionOptions = await _fbOptionRepository.GetAll();

                List <FeedbackOption> options = questionOptions.Where(x => x.QuestionId == fbQuestion.Id).ToList();
                feedbackVM.FeedbackOptions = options;

                allQuestions.Add(feedbackVM);
            }

            return(allQuestions);
        }
示例#4
0
        public int Insert(FeedbackVM item)
        {
            List <Feedback> feed = new List <Feedback>();

            feed.Add(new Feedback {
                PostDate = DateTime.Now, PostUserID = item.PostUserID, PortalUserID = item.PortalUserID, FeedbackTypeId = item.FeedbackTypeId, Title = item.Title, Description = item.Description, IsReviewed = false, FeedbackLang = 1
            });
            Context.Feedbacks.AddRange(feed);
            int result = 0;

            try
            {
                // Your code...
                // Could also be before try if you know the exception occurs in SaveChanges

                result = Context.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            return(result);
        }
示例#5
0
 public static void UpdateFeedback(this Feedback item, FeedbackVM itemVM)
 {
     item.Name        = itemVM.Name;
     item.Email       = itemVM.Email;
     item.Message     = itemVM.Message;
     item.Status      = itemVM.Status;
     item.CreatedDate = DateTime.Now;
 }
示例#6
0
        public ActionResult Feedback(int id)
        {
            FeedbackVM feedback = new FeedbackVM();

            feedback.feedback   = db.feedback.Where(s => s.Assessment.id == id).ToList();
            feedback.assessment = db.assessments.Where(a => a.id == id).Single();
            return(View(feedback));
        }
示例#7
0
        public FeedbackPage()
        {
            ApplicationBar      = new ApplicationBar();
            ApplicationBar.Mode = ApplicationBarMode.Default;

            sendButton.IconUri = new Uri("/HockeyApp.Content/Send.png", UriKind.Relative);
            sendButton.Text    = "Send message";
            sendButton.Click  += async(sender, e) =>
            {
                object focusObj = FocusManager.GetFocusedElement();
                if (focusObj != null && focusObj is TextBox)
                {
                    var binding = (focusObj as TextBox).GetBindingExpression(TextBox.TextProperty);
                    binding.UpdateSource();
                }
                await VM.SubmitForm();
            };

            answerButton.IconUri = new Uri("/HockeyApp.Content/Reply.png", UriKind.Relative);
            answerButton.Text    = "Answer";
            answerButton.Click  += (sender, e) =>
            {
                VM.SwitchToMessageForm();
            };

            Action <bool> showFormAppBarAction = (switchToForm) =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    if (switchToForm)
                    {
                        ShowFormAppBar();
                    }
                    else
                    {
                        ShowListAppBar();
                    }
                });
            };

            showFormAppBarAction(false);

            this.VM = new FeedbackVM(showFormAppBarAction);

            InitializeComponent();

            /*
             * ApplicationBar.IsMenuEnabled = true;
             * ApplicationBarMenuItem menuItem1 = new ApplicationBarMenuItem();
             * menuItem1.Text = "menu item 1";
             * ApplicationBar.MenuItems.Add(menuItem1);
             */
        }
示例#8
0
        public ActionResult Feedback(int id)
        {
            if (db.assessments.Where(a => a.id == id).Count() == 0 || db.assessments.Where(a => a.id == id).Single().Student.userName != User.Identity.Name)
            {
                return(RedirectToAction("Index", "Home"));
            }
            FeedbackVM feedback = new FeedbackVM();

            feedback.feedback   = db.feedback.Where(s => s.Assessment.Student.userName == User.Identity.Name && s.Assessment.id == id).ToList();
            feedback.assessment = db.assessments.Where(a => a.id == id).Single();
            return(View(feedback));
        }
示例#9
0
        public ActionResult SendFeedback(FeedbackVM data)
        {
            string content = "From:" + data.Name + " " + data.Email + "<br/>" + data.Message;

            Parallel.Invoke(() =>
            {
                Common.Tools.Mailer.SendMailSpecific(content,

                                                     ConfigurationManager.AppSettings["ToEmail"],
                                                     data.Subject);
            });
            return(Json("ok", JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(FeedbackVM feedbackvm)
        {
            userfeedback f = new userfeedback
            {
                feedback = feedbackvm.feedback,
                user_id  = feedbackvm.Userquiz.user_id,
                quiz_id  = feedbackvm.Userquiz.quiz_id
            };

            service.Add(f);
            service.Commit();
            return(RedirectToAction("Index"));
        }
示例#11
0
        public IActionResult Details(int OutfitId)
        {
            var               Outfit    = OutfitRepository.Get(OutfitId);
            var               userId    = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            string            userName  = WindowsIdentity.GetCurrent().Name.ToString();
            List <FeedbackVM> feedModel = new List <FeedbackVM>();
            var               feeds     = feedbackRepository.GetFeedbacks(OutfitId);

            foreach (Feedback f in feeds)
            {
                FeedbackVM feedVM;

                if (f.CustomerId == userId)
                {
                    feedVM = new FeedbackVM
                    {
                        UserName  = userName,
                        OutfitId  = f.OutfitId,
                        Rating    = f.Rating,
                        Comment   = f.Comment,
                        CommentId = f.Id,
                        IsUsers   = true
                    };
                }
                else
                {
                    feedVM = new FeedbackVM
                    {
                        UserName  = userName,
                        OutfitId  = f.OutfitId,
                        Rating    = f.Rating,
                        Comment   = f.Comment,
                        CommentId = f.Id,
                        IsUsers   = false
                    };
                }
                feedModel.Add(feedVM);
            }
            double rating = feedbackRepository.OutfitRating(OutfitId);


            OutfitDetailsViewModel model = new OutfitDetailsViewModel
            {
                Feedbacks = feedModel,
                Outfit    = Outfit,
                Rating    = rating
            };

            return(View(model));
        }
示例#12
0
        public IActionResult Upsert(int?id)
        {
            FeedbackVM form = new FeedbackVM();

            //if (id == null)
            //{
            //    return View(form);
            //}
            //form = _unitOfWork.Feedbacks.Get(id.GetValueOrDefault());
            //if (form == null)
            //{
            //    return NotFound();
            //}
            return(View(form));
        }
示例#13
0
        public async Task GetFeedbackQnsByIdAsync_ShouldReturnGetFeedbackQns_FeedbackQnExists()
        {
            int        id       = 1;
            FeedbackVM feedback = new FeedbackVM()
            {
                Id          = 1,
                Question    = "How is the event?",
                QuestionTye = "MultipleAnswer"
            };

            _feedbackRepository.Setup(x => x.GetFeedbackQuestionById(id)).ReturnsAsync(feedback);
            FeedbackVM result = await feedbackController.Get(id);

            Assert.AreEqual(feedback.Id, result.Id);
            Assert.AreEqual(feedback.Question, result.Question);
            Assert.AreEqual(feedback.QuestionTye, result.QuestionTye);
        }
示例#14
0
        public async Task GetFeedbackQnsAsync_ShouldReturnFeedbackQns_FeedbackQnExists()
        {
            List <FeedbackVM> feedbackVMs = new List <FeedbackVM>();
            FeedbackVM        feedback    = new FeedbackVM()
            {
                Id          = 1,
                Question    = "How is the event?",
                QuestionTye = "MultipleAnswer"
            };

            feedbackVMs.Add(feedback);
            _feedbackRepository.Setup(x => x.GetFeedbackQuestions()).ReturnsAsync(feedbackVMs);

            IEnumerable <FeedbackVM> result = await feedbackController.Get();

            Assert.IsNotEmpty(result);
        }
示例#15
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 }));
 }
示例#16
0
        public ActionResult AddFeedback(FeedbackVM response)
        {
            int id = Int32.Parse(Request.Form ["assessment.id"]);

            // add the response
            Feedback fb = new CPWeb.Feedback();

            fb.Assessment = db.assessments.Where(a => a.id == id).Single();
            fb.date       = DateTime.Now;
            fb.feedback   = Request.Form["response.feedback"];
            fb.user       = User.Identity.Name;

            db.feedback.Add(fb);

            db.SaveChanges();

            return(RedirectToAction("Feedback", new { id = id }));
        }
示例#17
0
        public async Task <FeedbackVM> GetFeedbackQuestionById(int id)
        {
            FeedbackVM feedbackVM = new FeedbackVM();


            var fbQuestion = await _fbQuestionRepository.Get(id);

            feedbackVM.Id              = fbQuestion.Id;
            feedbackVM.Question        = fbQuestion.Question;
            feedbackVM.ParticipantType = fbQuestion.ParticipantType;
            feedbackVM.QuestionTye     = fbQuestion.QuestionTye;
            var fbOptions = await _fbOptionRepository.GetAll();

            List <FeedbackOption> options = fbOptions.Where(x => x.QuestionId == fbQuestion.Id).ToList();

            feedbackVM.FeedbackOptions = options;

            return(feedbackVM);
        }
示例#18
0
        public async Task PostFbQuestionsByPartIdAsync_ShouldPostFbQuestionsByPartId()
        {
            PostFeedback postFeedback = new PostFeedback();

            postFeedback.ParticipantType = "Participated";
            List <FeedbackVM> feedbackVMs = new List <FeedbackVM>();
            FeedbackVM        feedback    = new FeedbackVM()
            {
                Id          = 1,
                Question    = "How is the event?",
                QuestionTye = "MultipleAnswer"
            };

            feedbackVMs.Add(feedback);
            _feedbackRepository.Setup(x => x.GetFeedbackQuestionsByParticipantType(postFeedback)).ReturnsAsync(feedbackVMs);
            IEnumerable <FeedbackVM> result = await feedbackController.PostFeedbackQuestionsByParticipantType(postFeedback);

            Assert.IsNotEmpty(result);
        }
示例#19
0
        public async Task <ActionResult> Create(FeedbackVM feedbackVM)
        {
            await Task.Delay(700);

            if (!ModelState.IsValid)
            {
                if (feedbackVM.ProductId.HasValue)
                {
                    ViewBag.ProductId = feedbackVM.ProductId;
                }

                return(PartialView("_Create", feedbackVM));
            }

            await _feedbackService.CreateAsync(Mapper.Map <FeedbackDTO>(feedbackVM));

            var response = Mapper.Map <ResponseVM>(_responseService.Create(true,
                                                                           "Cпасибо за ваш отзыв. Нам важно ваше мнение!"));

            return(Json(response));
        }
示例#20
0
        public static object InsertFeedback(FeedbackVM item)
        {
            //if (Utils.LoggedUser == null)
            //{
            //    Response.Redirect("~/login");
            //}
            //else
            //{
            //    lblEmail.Text = Utils.LoggedUser.Email;
            //    lblName.Text = Utils.LoggedUser.Name;
            //}
            if (Utils.LoggedUser != null)
            {
                item.PortalUserID = (int)Utils.LoggedUser.PortalUserId;
                item.PostUserID   = Utils.LoggedUser.UserId;
            }
            else
            {
                return(Utils.ServiceResponse("F034", new ModelResponse(101), null));
            }


            return(Mgr.Insert(item));
        }
示例#21
0
        public async Task <IEnumerable <FeedbackVM> > GetFeedbackQuestions()
        {
            List <FeedbackVM> allQuestions = new List <FeedbackVM>();

            var fbAllQuestions = await _fbQuestionRepository.GetAll();

            foreach (var fbQuestion in fbAllQuestions)
            {
                FeedbackVM feedbackVM = new FeedbackVM();
                feedbackVM.Id              = fbQuestion.Id;
                feedbackVM.Question        = fbQuestion.Question;
                feedbackVM.ParticipantType = fbQuestion.ParticipantType;
                feedbackVM.QuestionTye     = fbQuestion.QuestionTye;

                var questionOptions = await _fbOptionRepository.GetAll();

                int optionCnt = questionOptions.Where(x => x.QuestionId == fbQuestion.Id).Count();
                feedbackVM.OptionsCount = optionCnt;

                allQuestions.Add(feedbackVM);
            }

            return(allQuestions);
        }
示例#22
0
 public void Show(string trainingMatchcode)
 {
     var vm = new FeedbackVM{ TrainingMatchcode = trainingMatchcode };
     Render(vm);
 }
 public FeedbackController()
 {
     service    = new FeedbackService();
     feedbackVM = new FeedbackVM();
 }
示例#24
0
 private void Render(FeedbackVM vm)
 {
     _portal.SharedResponse = _portal.View["Feedback.Main.html", vm];
 }
示例#25
0
 public void Retry(string trainingMatchcode, string email, int score, string suggestions, string error)
 {
     var vm = new FeedbackVM { TrainingMatchcode = trainingMatchcode, Email = email, Score = score, Suggestions = suggestions, Error = error };
     Render(vm);
 }
示例#26
0
 public void Ack(string trainingMatchcode)
 {
     var vm = new FeedbackVM { TrainingMatchcode = trainingMatchcode };
     _portal.SharedResponse = _portal.View["Feedback.Ack.html", vm];
 }
示例#27
0
 public int Insert(FeedbackVM item)
 {
     return(_repo.Insert(item));
 }