Exemplo n.º 1
0
        public IActionResult AddFeedback()
        {
            //create list of users for select list options
            IEnumerable <ApplicationUser> userList =
                context
                .ApplicationUsers
                .ToList();
            AddFeedbackViewModel addFeedbackViewModel = new AddFeedbackViewModel(userList);

            return(View(addFeedbackViewModel));
        }
        public ContentResult AddFeedback(AddFeedbackViewModel viewModel)
        {
            var feedback = new ServiceLayer.Feedback.Models.Feedback
            {
                StudentEmail = User.Identity.Name,
                Text         = viewModel.Text
            };

            _feedbackFacade.InsertFeedback(feedback);

            return(Content("Uw feedback werd goed ontvangen"));
        }
Exemplo n.º 3
0
        public IActionResult AddFeedback(AddFeedbackViewModel addFeedbackViewModel)
        {
            if (ModelState.IsValid)
            {   //find identity of logged in user
                string UsersName = User.Identity.Name;
                //call database for user object
                ApplicationUser CurrentUser = context.ApplicationUsers.Single
                                                  (c => c.UserName == UsersName);

                Feedback newFeedback = new Feedback
                {   //collect ID of user object for record
                    ApplicationUserID = CurrentUser.Id,
                    ProviderName      = CurrentUser.AssociateName,
                    EntryDate         = DateTime.Now,
                    MentorID          = addFeedbackViewModel.MentorID,
                    ManagerID         = addFeedbackViewModel.ManagerID,
                    Focus             = addFeedbackViewModel.Focus,
                    Accomplishment    = addFeedbackViewModel.Accomplishment,
                    Confidence        = addFeedbackViewModel.Confidence,
                    ILikeNotes        = addFeedbackViewModel.ILikeNotes,
                    IWishNotes        = addFeedbackViewModel.IWishNotes,
                    ManagerNotes      = addFeedbackViewModel.ManagerNotes
                };


                //find mentorID and name using their ID from the feedback
                ApplicationUser Mentor = context.ApplicationUsers.Single
                                             (c => c.Id == newFeedback.MentorID);
                newFeedback.MentorName = Mentor.AssociateName;
                //grab their email
                string recepientMentor = Mentor.Email;
                //call email method, passing in address
                EmailNotification.SendEmail(recepientMentor);

                //find manager using their ID from the feedback
                ApplicationUser Manager = context.ApplicationUsers.Single
                                              (c => c.Id == newFeedback.ManagerID);
                newFeedback.ManagerName = Manager.AssociateName;
                //grab their email
                string recepientManager = Manager.Email;
                //call email method, passing in address-LOOK AT WAY TO DRY REPEAT
                EmailNotification.SendEmail(recepientManager);

                //add and update database
                context.Feedbacks.Add(newFeedback);
                context.SaveChanges();

                //return to home feedback screen
                return(Redirect("/Feedback"));
            }
            //return to form if model does not validate
            return(View(addFeedbackViewModel));
        }