Example #1
0
        public PartialViewResult FeedbackListInfo(SearchFeedbacksInfoViewModel searchInfo)
        {
            var user = _userProfileService.GetUserProfile(u => u.Id == searchInfo.UserId, i => i.FeedbacksMy);

            if (user != null)
            {
                var modelFeedbacks          = Mapper.Map <IEnumerable <Feedback>, IEnumerable <FeedbackViewModel> >(user.FeedbacksMy);
                FeedbackListViewModel model = new FeedbackListViewModel
                {
                    Feedbacks = modelFeedbacks,
                    PageInfo  = new PageInfoViewModel
                    {
                        PageSize   = 4,
                        PageNumber = searchInfo.Page,
                        TotalItems = modelFeedbacks.Count()
                    },
                    SearchInfo = new SearchViewModel
                    {
                        Page = searchInfo.Page
                    }
                };
                return(PartialView("_FeedbackListInfo", model));
            }
            return(PartialView("_NoResults"));
        }
        public ActionResult Index(int id = 1)
        {
            var page            = id;
            var totalItemsCount = this.feedRepo.All().Count();
            var totalPages      = (int)Math.Ceiling((double)totalItemsCount / (double)ItemsPerPage);
            var itemsToSkip     = (page - 1) * ItemsPerPage;

            var feedbacks = this.Cache.Get(
                "feedback",
                () => this.feedRepo.All()
                .OrderBy(x => x.CreatedOn)
                .Skip(itemsToSkip)
                .Take(ItemsPerPage)
                .To <FeedbackViewModel>()
                .ToList(),
                20);

            var listViewModel = new FeedbackListViewModel
            {
                CurrentPage = page,
                TotalPages  = totalPages,
                Feedbacks   = feedbacks
            };

            return(this.View(listViewModel));
        }
Example #3
0
 public ActionResult Index(FeedbackViewModel submitModel)
 {
     using (var dbContext = FeedbackDbContext.Create())
     {
         if (ModelState.IsValid)
         {
             var model = new Data.Feedback
             {
                 Content         = submitModel.Content,
                 CreateTimestamp = DateTimeOffset.UtcNow,
                 EmailAddress    = submitModel.EmailAddress
             };
             dbContext.Feedbacks.Add(model);
             dbContext.SaveChanges();
             return(RedirectToAction(nameof(Index)));
         }
         var viewModel = new FeedbackListViewModel
         {
             Content      = submitModel.Content,
             EmailAddress = submitModel.EmailAddress
         };
         LoadFeedbackList(viewModel, dbContext);
         return(View(viewModel));
     }
 }
        public ActionResult Index(int id = 1)
        {
            FeedbackListViewModel viewModel;

            if (this.HttpContext.Cache["Feedback_page_" + id] != null)
            {
                viewModel = (FeedbackListViewModel)this.HttpContext.Cache["Feedback_page_" + id];
            }
            else
            {
                var page          = id;
                var allItemsCount = this.feedbacks.All().Count();
                var totalPages    = (int)Math.Ceiling(allItemsCount / (decimal)ItemsPerPage);
                var feedbacks     = this.feedbacks
                                    .All()
                                    .OrderBy(x => x.CreatedOn)
                                    .ThenBy(x => x.Id)
                                    .Skip((page - 1) * ItemsPerPage)
                                    .Take(ItemsPerPage)
                                    .Project().To <FeedbackViewModel>()
                                    .ToList();

                viewModel = new FeedbackListViewModel()
                {
                    CurrentPage = page,
                    TotalPages  = totalPages,
                    Feedbacks   = feedbacks
                };

                var cacheAbsoluteExpiration = DateTime.Now.AddMinutes(1);
                this.HttpContext.Cache.Add("Feedback_page_" + id, viewModel, null, cacheAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
            }

            return(this.View(viewModel));
        }
Example #5
0
 private static void LoadFeedbackList(FeedbackListViewModel viewModel, FeedbackDbContext dbContext)
 {
     viewModel.SubmittedFeedbacks = dbContext.Feedbacks.Select(f => new FeedbackViewModel
     {
         Content        = f.Content,
         EmailAddress   = f.EmailAddress,
         SentimentScore = f.SentimentScore
     }).ToList();
 }
Example #6
0
        public IActionResult List()
        {
            var model = new FeedbackListViewModel()
            {
                YourTeamFeedbackRequests = new List <FeedbackRequest>()
                {
                    new FeedbackRequest()
                    {
                        FromTeam = "Your team", ToTeam = "Strategy Planning", Title = "Request 1", RequestedDateTime = DateTime.Today, Description = "desc 1 hsagdhag jsahd gadsjh asdh ", Status = "Started"
                    },
                    new FeedbackRequest()
                    {
                        FromTeam = "Your team", ToTeam = "IT Software Development", Title = "Request 2", RequestedDateTime = DateTime.Today, Description = "desc 2 hsagdhag jsahd gadsjh asdh ", Status = "Posted"
                    },
                    new FeedbackRequest()
                    {
                        FromTeam = "Your team", ToTeam = "Finance", Title = "Request 1", RequestedDateTime = DateTime.Today, Description = "desc 3 hsagdhag jsahd gadsjh asdh ", Status = "Feedback Available"
                    },
                },

                OtherTeamFeedbackRequests = new List <FeedbackRequest>()
                {
                    new FeedbackRequest()
                    {
                        FromTeam = "Human Resources", ToTeam = "Your team", Title = "Request 1", RequestedDateTime = DateTime.Today, Description = "desc 1 hsagdhag jsahd gadsjh asdh ", Status = "1 week old"
                    },
                    new FeedbackRequest()
                    {
                        FromTeam = "IT Software Development", ToTeam = "Your team", Title = "Request 2", RequestedDateTime = DateTime.Today, Description = "desc 2 hsagdhag jsahd gadsjh asdh ", Status = "2 days old"
                    },
                    new FeedbackRequest()
                    {
                        FromTeam = "IT Infrastructure", ToTeam = "Your team", Title = "Request 1", RequestedDateTime = DateTime.Today, Description = "desc 3 hsagdhag jsahd gadsjh asdh ", Status = "new"
                    },
                },

                ArchivedFeedbackRequests = new List <FeedbackRequest>()
                {
                    new FeedbackRequest()
                    {
                        FromTeam = "Human Resources", ToTeam = "Your team", Title = "Learning materials for staff", RequestedDateTime = DateTime.Today.AddDays(-60), Description = "desc 1 hsagdhag jsahd gadsjh asdh ", Status = "1 week old"
                    },
                    new FeedbackRequest()
                    {
                        FromTeam = "IT Software Development", ToTeam = "Your team", Title = "Re-organise dContacts and Organisations data", RequestedDateTime = DateTime.Today.AddDays(-72), Description = "desc 2 hsagdhag jsahd gadsjh asdh ", Status = "2 days old"
                    },
                    new FeedbackRequest()
                    {
                        FromTeam = "IT Infrastructure", ToTeam = "Your team", Title = "Comms plan for IT rollout of Sharepoint", RequestedDateTime = DateTime.Today.AddDays(-89), Description = "desc 3 hsagdhag jsahd gadsjh asdh ", Status = "new"
                    },
                }
            };



            return(View(model));
        }
        public async Task <ActionResult> Negative()
        {
            var userId    = User.Identity.GetUserId <int>();
            var feedbacks = await feedbackService.GetFeedbacksAsync(f => f.UserToId == userId && f.Grade == Emotions.Bad, i => i.UserTo);

            var modelFeedbacks = Mapper.Map <IEnumerable <Feedback>, IEnumerable <FeedbackViewModel> >(feedbacks);
            var model          = new FeedbackListViewModel()
            {
                Feedbacks = modelFeedbacks
            };

            return(View(model));
        }
Example #8
0
        public ActionResult Negative()
        {
            var currentUserId = User.Identity.GetUserId();
            var user          = _userProfileService.GetUserProfile(u => u.Id == currentUserId, i => i.FeedbacksMy);

            if (user != null)
            {
                var positiveFeedbacks      = user.FeedbacksMy.Where(f => f.Grade == Emotions.Bad);
                var positiveFeedbacksModel = Mapper.Map <IEnumerable <Feedback>, IEnumerable <FeedbackViewModel> >(positiveFeedbacks);
                var model = new FeedbackListViewModel()
                {
                    Feedbacks = positiveFeedbacksModel
                };
                return(View(model));
            }
            return(HttpNotFound());
        }
Example #9
0
        public ActionResult Index()
        {
            var viewModel = new FeedbackListViewModel();

            using (var dbContext = FeedbackDbContext.Create())
            {
                try
                {
                    dbContext.Database.Initialize(false);
                    LoadFeedbackList(viewModel, dbContext);
                }
                catch (Exception e)
                {
                    Debug.WriteLine($"Could not initialize database, probably because it doesn't exist yet. It'll get created by the VSTS Delivery Pipeline!\r\n{e}");
                    // NOTE: Obviously in real systems you wouldn't emit your connection string for the world to see! :)
                    ViewData["Message"] = $"Attempted using connection string: {dbContext.Database.Connection.ConnectionString}\r\n{e.ToString()}";
                }
            }
            return(View(viewModel));
        }
        public async Task <IActionResult> ViewFeedBack()
        {
            var user     = UserModel.GetAuthenticatedUser(User.Identity);
            var userRole = await _userRolesRepository.GetAsync(user.Email.ToLower());

            if (userRole == null)
            {
                return(View("AccessDenied"));
            }

            var feedback = await _feedbackRepository.GetFeedbacksAsync();

            feedback = feedback.OrderByDescending(x => x.Created);

            var viewModel = new FeedbackListViewModel
            {
                FeedbackList = feedback
            };

            return(View(viewModel));
        }
Example #11
0
        public PartialViewResult FeedbackList(string userId, string filter, int page = 1)
        {
            FeedbackListViewModel model = new FeedbackListViewModel();
            var currentUserId           = User.Identity.GetUserId();
            var user = _userProfileService.GetUserProfile(u => u.Id == currentUserId, i => i.FeedbacksMy.Select(f => f.Order.Offer), i => i.FeedbacksMy.Select(f => f.UserFrom));

            if (user != null)
            {
                IEnumerable <Feedback>    feedbacks          = user.FeedbacksMy;
                IList <FeedbackViewModel> feedbackViewModels = Mapper.Map <List <Feedback>, List <FeedbackViewModel> >(feedbacks.ToList());
                model.Feedbacks = feedbackViewModels.Skip((page - 1) * pageSize).Take(pageSize).ToList();
                model.PageInfo  = new PageInfoViewModel()
                {
                    PageSize   = pageSize,
                    PageNumber = page,
                    TotalItems = feedbacks.Count()
                };
                return(PartialView("_FeedbackList", model));
            }
            return(PartialView("_FeedbackList", model));
        }
        public ActionResult Display(int id, int page = 1)
        {
            var postViewModel = this.posts.All().Where(x => x.Id == id)
                                .ProjectTo <QuestionDisplayViewModel>().FirstOrDefault();

            if (postViewModel == null)
            {
                return(this.HttpNotFound("No such post!"));
            }

            var postFeedbacks = this.feedbacks.All().Where(x => x.PostId == id);
            var allItemsCount = postFeedbacks.Count();
            var totalPages    = (int)Math.Ceiling(allItemsCount / (decimal)ItemsPerPage);
            var itemsToSkip   = (page - 1) * ItemsPerPage;

            var feedbacks = postFeedbacks
                            .ProjectTo <FeedbackDisplayViewModel>()
                            .OrderByDescending(x => x.VotesCount)
                            .ThenByDescending(x => x.CreatedOn)
                            .ThenBy(x => x.Id)
                            .Skip(itemsToSkip)
                            .Take(ItemsPerPage)
                            .ToList();

            var feedbackViewModel = new FeedbackListViewModel
            {
                PostId      = id,
                PostTitle   = postViewModel.Title,
                CurrentPage = page,
                TotalPages  = totalPages,
                Feedbacks   = feedbacks
            };

            postViewModel.FeedbackListViewModel = feedbackViewModel;

            return(this.View(postViewModel));
        }
Example #13
0
 public FeedbackPage()
 {
     InitializeComponent();
     BindingContext = model = new FeedbackListViewModel();
 }