public IHttpActionResult PutUserFeedback(int id, UserFeedback userFeedback)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != userFeedback.Id)
            {
                return(BadRequest());
            }

            db.Entry(userFeedback).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserFeedbackExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult FeedBack(UserFeedbackModel Model)
        {
            var feedback = new UserFeedback();

            feedback.Date        = DateTime.Now.ToUniversalTime();
            feedback.Description = Model.Description;
            feedback.Rating      = 0;
            feedback.UserId      = Model.UserId;

            try
            {
                using (AppDBContext context = new AppDBContext())
                {
                    try
                    {
                        var repo = new UserFeedbackRepository(context);
                        repo.Add(feedback);
                    }
                    catch (Exception ex)
                    {
                        return(InternalServerError(ex));
                    }
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                Logger.Log(typeof(UserController), ex.Message + ex.StackTrace, LogType.ERROR);
                return(InternalServerError());
            }
        }
        public async Task <IActionResult> AddFeedBack([FromBody] FeedBackDto feedBackDto)
        {
            try
            {
                var userFeedback = new UserFeedback()
                {
                    FeedbackType = feedBackDto.FeedbackType,
                    Description  = feedBackDto.Description,
                    FirstName    = feedBackDto.FirstName,
                    LastName     = feedBackDto.LastName,
                    Email        = feedBackDto.Email
                };

                await _userFeedBackRepository.AddFeedBack(userFeedback);

                await _context.SaveChangesAsync();

                return(Ok(new
                {
                    userFeedback.Id,
                    userFeedback.FeedbackType,
                    userFeedback.Description,
                    userFeedback.FirstName,
                    userFeedback.LastName,
                    userFeedback.Email
                }));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Beispiel #4
0
        public async Task <ActionResult <UserFeedback> > ReceiveFeedback(UserFeedback feedback, [FromServices] DaprClient daprClient)
        {
            _logger.LogInformation($"Feedback received {feedback.Id}");

            /*Read from state store and update name if key - first name matches
             * Uses .NET SDK Method to retrieve from the state store */
            //Equivalent to call - http://localhost:3500/v1.0/state/<store-name>/<value>

            var state = await daprClient.GetStateEntryAsync <UserFeedback>(StoreName, feedback.FirstName);

            state.Value ??= new UserFeedback()
            {
                Id = feedback.FirstName
            };
            state.Value.EmailId         = feedback.EmailId;
            state.Value.Id              = feedback.Id;
            state.Value.Message         = feedback.Message;
            state.Value.FirstName       = feedback.FirstName;
            state.Value.LastName        = feedback.LastName;
            state.Value.DoesLikeSession = feedback.DoesLikeSession;

            _logger.LogInformation($"Feedback received {feedback.Id} - {feedback.FirstName} {feedback.LastName}");

            //save in the state store
            await state.SaveAsync();

            return(state.Value);
        }
Beispiel #5
0
        public void ReturnsUserFeedbackWithValidRequest()
        {
            UserFeedback testFeedback = new UserFeedback
            {
                Id                 = 1234,
                UserName           = "******",
                EmailAddress       = "*****@*****.**",
                HomeAddress        = "123 test address, leeds",
                IsHappyWithService = true,
                LevelOfBrightness  = 9
            };

            var testFeedBackBytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(testFeedback));

            mockSession.Setup(s => s.TryGetValue(It.IsAny <string>(), out testFeedBackBytes)).Returns(true);

            UserFeedback feedback = new UserFeedback
            {
                Id                 = 0,
                UserName           = "******",
                EmailAddress       = "*****@*****.**",
                HomeAddress        = "123 test address, leeds",
                IsHappyWithService = true,
                LevelOfBrightness  = 92
            };

            feedbackRepoMock.Setup(m => m.AddFeedback(feedback)).Returns(testFeedback);
            feedbackController.PostSummary();
            Assert.AreNotEqual(feedback.Id, testFeedback.Id);
            Assert.IsNotNull(testFeedback);
            feedbackRepoMock.Verify(mock => mock.AddFeedback(It.IsAny <UserFeedback>()), Times.Once());
        }
        public async Task <UserFeedback> SubmitFeedback(UserFeedback userFeedback)
        {
            try
            {
                var feedback = await Context.UserFeedbacks.Where(f => f.UserId == userFeedback.UserId).FirstOrDefaultAsync();

                if (feedback == null)
                {
                    await Context.UserFeedbacks.AddAsync(userFeedback);
                    await SaveAll();

                    return(userFeedback);
                }

                feedback.JobSatisfaction         = userFeedback.JobSatisfaction;
                feedback.EnvironmentSatisfaction = userFeedback.EnvironmentSatisfaction;
                feedback.WorkLifeBalance         = userFeedback.WorkLifeBalance;
                feedback.Datetime = userFeedback.Datetime;

                await SaveAll();

                return(feedback);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Методот <c>Contact</c>
        /// се справува со GET барањата на патеката /Home/Contact и
        /// проверува дали најавениот корисник ја има оценето нашата апликација
        /// и соодветно враќа поглед
        /// </summary>
        /// <returns>
        /// Доколку корисникот не е најавен се враќа поглед од Контакт страната,
        /// во спротивно се враќа Поглед заедно со објект од типот UserFeedback
        /// </returns>
        public ActionResult Contact()
        {
            ViewBag.NotLogged = false;
            ViewBag.Message   = "Контакт страна";
            UserFeedback uf = db.UserFeedbacks.FirstOrDefault(p => p.CurrentUserUsername.Equals(this.User.Identity.Name));

            if (uf != null)
            {
                ViewBag.AlreadySent = "yes";
            }
            else
            {
                ViewBag.AlreadySent = "no";
            }

            ViewBag.Feedbacks = db.UserFeedbacks.ToList();
            if (this.User.Identity.Name != null && !this.User.Identity.Name.Equals(""))
            {
                UserFeedback model = new UserFeedback();
                model.CurrentUserUsername = this.User.Identity.Name;

                return(View(model));
            }
            else
            {
                ViewBag.NotLogged = true;
                ViewBag.Message   = "Не можете да оставите повратна информација доколку не сте логирани !!!";

                return(View());
            }
        }
Beispiel #8
0
        private bool ValidateDataPatialReport()
        {
            _isValidActivityMade = true;
            _isValidWeek         = true;
            _activityMades       = new List <ActivityMade>();
            PartialReportValidator    partialReportValidator = new PartialReportValidator();
            ValidationResult          dataValidationResult   = partialReportValidator.Validate(_partialReport);
            IList <ValidationFailure> validationFailures     = dataValidationResult.Errors;
            UserFeedback userFeedback = new UserFeedback(FormGrid, validationFailures);

            userFeedback.ShowFeedback();
            ValidateActivityMade();
            ValidateWeek(ListBoxP1);
            ValidateWeek(ListBoxP2);
            ValidateWeek(ListBoxP3);
            ValidateWeek(ListBoxP4);
            ValidateWeek(ListBoxP5);

            ValidateWeek(ListBoxR1);
            ValidateWeek(ListBoxR2);
            ValidateWeek(ListBoxR3);
            ValidateWeek(ListBoxR4);
            ValidateWeek(ListBoxR5);

            return(dataValidationResult.IsValid && _isValidActivityMade && _activityMades.Count != 0 && _isValidWeek);
        }
Beispiel #9
0
 internal void SessionDelegate_InterruptionEnded(ARSession session)
 {
     UserFeedback.UnblurBackground();
     Session.Run(StandardConfiguration(), ARSessionRunOptions.ResetTracking | ARSessionRunOptions.RemoveExistingAnchors);
     RestartExperience(this);
     UserFeedback.ShowMessage("RESETTING SESSION");
 }
Beispiel #10
0
        public void ShouldCreateUserFeedbackWithConflictResultError()
        {
            var userFeedback = new UserFeedback()
            {
                UserProfileId = Hdid,
                CreatedBy     = Hdid,
                UpdatedBy     = Hdid,
            };

            DBResult <UserFeedback> mockedDBResult = new DBResult <UserFeedback>()
            {
                Status  = Database.Constants.DBStatusCode.Error,
                Payload = userFeedback,
            };

            Mock <IHttpContextAccessor> httpContextAccessorMock = CreateValidHttpContext(Token, UserId, Hdid);
            Mock <IUserFeedbackService> userFeedbackServiceMock = new Mock <IUserFeedbackService>();

            userFeedbackServiceMock.Setup(s => s.CreateUserFeedback(It.IsAny <UserFeedback>())).Returns(mockedDBResult);

            UserFeedbackController controller = new UserFeedbackController(userFeedbackServiceMock.Object, httpContextAccessorMock.Object);
            var actualResult = controller.CreateUserFeedback(Hdid, userFeedback);

            Assert.IsType <ConflictResult>(actualResult);
        }
Beispiel #11
0
        public void ShouldCreateUserFeedbackWithBadRequestResultError()
        {
            var userFeedback = new UserFeedback()
            {
                UserProfileId = Hdid,
                CreatedBy     = Hdid,
                UpdatedBy     = Hdid,
            };

            DBResult <UserFeedback> mockedDBResult = new DBResult <UserFeedback>()
            {
                Status = Database.Constants.DBStatusCode.Error,
            };

            Mock <IHttpContextAccessor> httpContextAccessorMock = CreateValidHttpContext(Token, UserId, Hdid);
            Mock <IUserFeedbackService> userFeedbackServiceMock = new Mock <IUserFeedbackService>();

            userFeedbackServiceMock.Setup(s => s.CreateUserFeedback(It.IsAny <UserFeedback>())).Returns(mockedDBResult);

            UserFeedbackController controller = new UserFeedbackController(userFeedbackServiceMock.Object, httpContextAccessorMock.Object);

#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
            var actualResult = controller.CreateUserFeedback(Hdid, null);
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
            Assert.IsType <BadRequestResult>(actualResult);
        }
        public void ShouldCreateUserFeedback()
        {
            UserFeedback expectedUserFeedback = new UserFeedback
            {
                Comment       = "Mocked Comment",
                Id            = Guid.NewGuid(),
                UserProfileId = "Mocked UserProfileId",
                IsSatisfied   = true,
                IsReviewed    = true
            };

            DBResult <UserFeedback> insertResult = new DBResult <UserFeedback>
            {
                Payload = expectedUserFeedback,
                Status  = DBStatusCode.Created
            };

            Mock <IFeedbackDelegate> userFeedbackDelegateMock = new Mock <IFeedbackDelegate>();

            userFeedbackDelegateMock.Setup(s => s.InsertUserFeedback(It.Is <UserFeedback>(r => r.Comment == expectedUserFeedback.Comment && r.Id == expectedUserFeedback.Id && r.UserProfileId == expectedUserFeedback.UserProfileId && r.IsSatisfied == expectedUserFeedback.IsSatisfied && r.IsReviewed == expectedUserFeedback.IsReviewed))).Returns(insertResult);

            IUserFeedbackService service = new UserFeedbackService(
                new Mock <ILogger <UserFeedbackService> >().Object,
                userFeedbackDelegateMock.Object,
                null
                );

            DBResult <UserFeedback> actualResult = service.CreateUserFeedback(expectedUserFeedback);

            Assert.Equal(DBStatusCode.Created, actualResult.Status);
            Assert.True(actualResult.Payload.IsDeepEqual(expectedUserFeedback));
        }
Beispiel #13
0
        private static void AddFeedbackToDb(UserFeedback feedback, SearchResult res)
        {
            try
            {
                string cnString = ConfigurationManager.AppSettings["SQLConnectionString"];

                string query = $@"
                        INSERT INTO [dbo].[questions]
                                (QnaId
                                ,Question)
                        VALUES
                                ('{res.QnaId}', '{feedback.userQuestion}') 
                ";

                using (var connection = new SqlConnection(cnString))
                {
                    connection.Open();

                    Submit_Tsql_NonQuery(connection, "3 - Inserts",
                                         query);
                }
            }
            catch (SqlException e)
            {
            }
        }
Beispiel #14
0
        public async Task Roundtrip_WithUserFeedback_Success()
        {
            // Arrange
            var feedback = new UserFeedback(
                SentryId.Create(),
                "Someone Nice",
                "*****@*****.**",
                "Everything is great!");

            using var envelope = Envelope.FromUserFeedback(feedback);

#if !NET461 && !NETCOREAPP2_1
            await
#endif
            using var stream = new MemoryStream();

            // Act
            await envelope.SerializeAsync(stream);

            stream.Seek(0, SeekOrigin.Begin);

            using var envelopeRoundtrip = await Envelope.DeserializeAsync(stream);

            // Assert

            // Can't compare the entire object graph because output envelope contains evaluated length,
            // which original envelope doesn't have.
            envelopeRoundtrip.Header.Should().BeEquivalentTo(envelope.Header);
            envelopeRoundtrip.Items.Should().ContainSingle();
            envelopeRoundtrip.Items[0].Payload.Should().BeOfType <JsonSerializable>()
            .Which.Source.Should().BeEquivalentTo(feedback);
        }
Beispiel #15
0
        public async Task <IActionResult> AddFeedBack([FromBody] UserFeedback userFeedBack)
        {
            try
            {
                var feedBack = await _userFeedBackRepository.AddFeedBack(userFeedBack);

                if (feedBack == null)
                {
                    return(NotFound());
                }

                return(Ok(new
                {
                    feedBack.Id,
                    feedBack.FeedbackType,
                    feedBack.Description,
                    feedBack.FirstName,
                    feedBack.LastName,
                    feedBack.Email
                }));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Beispiel #16
0
        public void StoreFeedbackNoUsernameNoFeedbackSubjectFeedbackRatingNoFeedback()
        {
            UserFeedback uf = new UserFeedback();

            uf.FeedbackRating = 4;
            uf.StoreFeedback("");
        }
Beispiel #17
0
        public async stt::Task UpdateUserFeedbackAsync()
        {
            moq::Mock <QuestionService.QuestionServiceClient> mockGrpcClient = new moq::Mock <QuestionService.QuestionServiceClient>(moq::MockBehavior.Strict);
            UpdateUserFeedbackRequest request = new UpdateUserFeedbackRequest
            {
                UserFeedback = new UserFeedback(),
                UpdateMask   = new wkt::FieldMask(),
            };
            UserFeedback expectedResponse = new UserFeedback
            {
                UserFeedbackName = UserFeedbackName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"),
                FreeFormFeedback = "free_form_feedbackab42f4bb",
                Rating           = UserFeedback.Types.UserFeedbackRating.Unspecified,
            };

            mockGrpcClient.Setup(x => x.UpdateUserFeedbackAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <UserFeedback>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            QuestionServiceClient client = new QuestionServiceClientImpl(mockGrpcClient.Object, null);
            UserFeedback          responseCallSettings = await client.UpdateUserFeedbackAsync(request.UserFeedback, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            UserFeedback responseCancellationToken = await client.UpdateUserFeedbackAsync(request.UserFeedback, request.UpdateMask, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #18
0
        public async Task <string> LikeDislikeComment(CommentFeedback commentFeedback)
        {
            string message  = "Feedback updated successfully";
            var    feedback = await _context.UserFeedback.Where(x => x.CommentId == commentFeedback.CommentId && x.UserId == commentFeedback.UserId).FirstOrDefaultAsync();

            if (feedback == null)
            {
                UserFeedback userFeedback = new UserFeedback();
                userFeedback.CommentId = commentFeedback.CommentId;
                userFeedback.UserId    = commentFeedback.UserId;
                userFeedback.IsLike    = commentFeedback.IsLike;
                userFeedback.IsDislike = !commentFeedback.IsLike;
                _context.UserFeedback.Add(userFeedback);
                await Save();
            }
            else
            {
                if (feedback.IsLike == commentFeedback.IsLike || feedback.IsDislike == !commentFeedback.IsLike)
                {
                    throw new Exception("You already " + (commentFeedback.IsLike ? "liked" : "disliked"));
                }

                feedback.IsLike                = commentFeedback.IsLike;
                feedback.IsDislike             = !commentFeedback.IsLike;
                _context.Entry(feedback).State = EntityState.Modified;
                await Save();
            }


            return(message);
        }
Beispiel #19
0
        public async Task <IActionResult> SubmitFeedback(UserFeedbackVM input)
        {
            var strList = new List <string> {
                input.Description
            };

            if (StrIsNull(strList) || input.Type == UserFeedbackType.未选择)
            {
                return(Json(new { result = false, contentNull = true, message = "必填项为空,请检查类型和描述是否已经选择和填写!" }));
            }
            var user         = GetUser();
            var userFeedback = new UserFeedback
            {
                Link              = EncodeFilterHelper.EncodeHtmlForLink(input.Link),
                Description       = EncodeFilterHelper.EncodeHtml(input.Description),
                ContactWay        = EncodeFilterHelper.EncodeHtml(input.ContactWay),
                Type              = input.Type,
                FeedbackIPAddress = GetClientIpAddress(),
                FeedUser          = user == null ? null : user
            };
            var r = await _userFeedback.AddOrEditAndSaveAsyn(userFeedback);

            if (r)
            {
                return(Json(new { result = true }));
            }
            return(Json(new { result = false, message = "提交失败!" }));
        }
Beispiel #20
0
        public (bool, List <UserFeedback>) IsTransferStashLootable()
        {
            if (!(_settings.GetLocal().SecureTransfers ?? true))
            {
                Logger.Debug("Secure transfers are disabled, ignoring stash loot safety checks.");
                return(true, new List <UserFeedback>());
            }

            if (RuntimeSettings.StashStatus != StashAvailability.CLOSED)
            {
                Logger.Info($"Delaying stash loot, stash status {RuntimeSettings.StashStatus} != CLOSED.");
                return(false, UserFeedback.FromTagSingleton("iatag_feedback_delaying_stash_loot_status"));
            }

            if (!GrimStateTracker.IsFarFromStash)
            {
                var distance = GrimStateTracker.Distance;
                if (distance.HasValue)
                {
                    Logger.Info($"Delaying stash loot, too close to stash. ({distance.Value}m away, minimum is {GrimStateTracker.MinDistance}m)");
                    return(false, UserFeedback.FromTagSingleton("iatag_feedback_too_close_to_stash"));
                }
                else
                {
                    //Logger.Info("Delaying stash loot, player location is unknown.");
                    return(false, UserFeedback.FromTagSingleton("iatag_feedback_stash_position_unknown"));
                }
            }


            return(true, new List <UserFeedback>());
        }
        public async Task Roundtrip_WithUserFeedback_Success()
        {
            // Arrange
            var feedback = new UserFeedback(
                new SentryId(Guid.NewGuid()),
                "*****@*****.**",
                "Everything sucks",
                "Donald J. Trump"
                );

            using var envelope = Envelope.FromUserFeedback(feedback);

            using var stream = new MemoryStream();

            // Act
            await envelope.SerializeAsync(stream);

            stream.Seek(0, SeekOrigin.Begin);

            using var envelopeRoundtrip = await Envelope.DeserializeAsync(stream);

            // Assert

            // Can't compare the entire object graph because output envelope contains evaluated length,
            // which original envelope doesn't have.
            envelopeRoundtrip.Header.Should().BeEquivalentTo(envelope.Header);
            envelopeRoundtrip.Items.Should().ContainSingle();

            var payloadContent = (envelopeRoundtrip.Items[0].Payload as JsonSerializable)?.Source;

            payloadContent.Should().BeEquivalentTo(feedback);
        }
Beispiel #22
0
        public void StoreFeedbackUsernameNoFeedbackSubjectNoFeedbackRatingFeedback()
        {
            UserFeedback uf = new UserFeedback();

            uf.FeedBack = "Test";
            uf.StoreFeedback("mikeofmacc");
        }
Beispiel #23
0
        private static async Task <ISerializable> DeserializePayloadAsync(
            Stream stream,
            IReadOnlyDictionary <string, object?> header,
            CancellationToken cancellationToken = default)
        {
            var payloadLength = header.GetValueOrDefault(LengthKey) switch
            {
                null => (long?)null,
                var value => Convert.ToInt64(value)
            };

            var payloadType = header.GetValueOrDefault(TypeKey) as string;

            // Event
            if (string.Equals(payloadType, TypeValueEvent, StringComparison.OrdinalIgnoreCase))
            {
                var bufferLength = (int)(payloadLength ?? stream.Length);
                var buffer       = await stream.ReadByteChunkAsync(bufferLength, cancellationToken).ConfigureAwait(false);

                var json = Json.Parse(buffer);

                return(new JsonSerializable(SentryEvent.FromJson(json)));
            }

            // User report
            if (string.Equals(payloadType, TypeValueUserReport, StringComparison.OrdinalIgnoreCase))
            {
                var bufferLength = (int)(payloadLength ?? stream.Length);
                var buffer       = await stream.ReadByteChunkAsync(bufferLength, cancellationToken).ConfigureAwait(false);

                var json = Json.Parse(buffer);

                return(new JsonSerializable(UserFeedback.FromJson(json)));
            }

            // Transaction
            if (string.Equals(payloadType, TypeValueTransaction, StringComparison.OrdinalIgnoreCase))
            {
                var bufferLength = (int)(payloadLength ?? stream.Length);
                var buffer       = await stream.ReadByteChunkAsync(bufferLength, cancellationToken).ConfigureAwait(false);

                var json = Json.Parse(buffer);

                return(new JsonSerializable(Transaction.FromJson(json)));
            }

            // Arbitrary payload
            var payloadStream = new PartialStream(stream, stream.Position, payloadLength);

            if (payloadLength != null)
            {
                stream.Seek(payloadLength.Value, SeekOrigin.Current);
            }
            else
            {
                stream.Seek(0, SeekOrigin.End);
            }

            return(new StreamSerializable(payloadStream));
        }
Beispiel #24
0
        public void StoreFeedbackNoUsernameFeedbackSubjectNoFeedbackRatingNoFeedback()
        {
            UserFeedback uf = new UserFeedback();

            uf.FeedbackSubject = "Test";
            uf.StoreFeedback("");
        }
        public void RestartExperience(NSObject sender)
        {
            if (!RestartExperienceButton.Enabled || IsLoadingObject)
            {
                return;
            }

            RestartExperienceButton.Enabled = false;

            UserFeedback.CancelAllScheduledMessages();
            UserFeedback.DismissPresentedAlert();
            UserFeedback.ShowMessage("STARTING A NEW SESSION");

            virtualObjectManager.RemoveAllVirtualObjects();
            AddObjectButton.SetImage(UIImage.FromBundle("add"), UIControlState.Normal);
            AddObjectButton.SetImage(UIImage.FromBundle("addPressed"), UIControlState.Highlighted);
            if (FocusSquare != null)
            {
                FocusSquare.Hidden = true;
            }
            ResetTracking();

            RestartExperienceButton.SetImage(UIImage.FromBundle("restart"), UIControlState.Normal);

            // Disable Restart button for a second in order to give the session enough time to restart.
            var when = new DispatchTime(DispatchTime.Now, new TimeSpan(0, 0, 1));

            DispatchQueue.MainQueue.DispatchAfter(when, () => SetupFocusSquare());
        }
Beispiel #26
0
        public void StoreFeedbackUsernameNoFeedbackSubjectFeedbackRatingNoFeedback()
        {
            UserFeedback uf = new UserFeedback();

            uf.FeedbackRating = 4;
            uf.StoreFeedback("mikeofmacc");
        }
Beispiel #27
0
        public void RedTextBoxTest()
        {
            Grid myGrid = new Grid();

            TextBox name = new TextBox
            {
                Text = "",
                Name = "TextBoxFirstName"
            };
            TextBox lastName = new TextBox
            {
                Text = "",
                Name = "TextBoxLastName"
            };

            myGrid.Children.Add(name);
            myGrid.Children.Add(lastName);

            User user = new User
            {
                Name     = name.Text,
                LastName = lastName.Text
            };

            UserValidator uv = new UserValidator();

            FluentValidation.Results.ValidationResult vr = uv.Validate(user);
            IList <ValidationFailure> l = vr.Errors;
            UserFeedback uf             = new UserFeedback(myGrid, l);

            uf.ShowFeedback();

            Assert.AreEqual(2, uf.ControlsThatHaveBeenPaintedInRed.Count);
        }
        public OperationReturnModel <string> SubmitUserFeedback(UserFeedback userFeedback)
        {
            var retVal = new OperationReturnModel <string>()
            {
                IsSuccess = false
            };

            try
            {
                (string Name, string EmailAddress)target = GetTarget(SelectedUserContext, AuthenticatedUser, userFeedback.Audience);

                var customer = GetCustomer(SelectedUserContext, AuthenticatedUser);

                var context = new UserFeedbackContext
                {
                    UserId             = AuthenticatedUser.UserId,
                    UserFirstName      = AuthenticatedUser.FirstName,
                    UserLastName       = AuthenticatedUser.LastName,
                    BranchId           = customer?.CustomerBranch,
                    CustomerNumber     = customer?.CustomerNumber,
                    CustomerName       = customer?.CustomerName,
                    SalesRepName       = customer?.Dsr?.Name,
                    SourceName         = AuthenticatedUser.Name,
                    TargetName         = target.Name,
                    SourceEmailAddress = AuthenticatedUser.EmailAddress,
                    TargetEmailAddress = target.EmailAddress,
                };

                var notification = new UserFeedbackNotification()
                {
                    BranchId       = customer?.CustomerBranch,
                    CustomerNumber = customer?.CustomerNumber,
                    Audience       = userFeedback.Audience,

                    Context      = context,
                    UserFeedback = userFeedback,
                };

                _userFeedbackLogic.SaveUserFeedback(context, userFeedback);
                _notificationHandler.ProcessNotification(notification);

                retVal.SuccessResponse = "Feedback processed successfully.";
                retVal.IsSuccess       = true;
            }
            catch (ApplicationException axe)
            {
                retVal.ErrorMessage = axe.Message;
                retVal.IsSuccess    = false;
                _log.WriteErrorLog("Application exception", axe);
            }
            catch (Exception ex)
            {
                retVal.ErrorMessage = "Could not complete the request. " + ex.Message;
                retVal.IsSuccess    = false;
                _log.WriteErrorLog("Unhandled exception", ex);
            }

            return(retVal);
        }
Beispiel #29
0
 private void Start()
 {
     if (Instance != null)
     {
         Destroy(this);
     }
     Instance = this;
 }
Beispiel #30
0
        public ActionResult DeleteConfirmed(int id)
        {
            UserFeedback userFeedback = db.UserFeedbacks.Find(id);

            db.UserFeedbacks.Remove(userFeedback);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #31
0
 public void Display(UserFeedback userFeedback)
 {
     switch (userFeedback)
     {
         case UserFeedback.TrackNotPlayable:
             _eventAggregator.Publish(new UserFeedbackMessage("This track is not playable."));
             break;
         case UserFeedback.SomeTracksNotPlayable:
             _eventAggregator.Publish(new UserFeedbackMessage("One or more of these tracks were not playable."));
             break;
         case UserFeedback.NoSearchTextEntered:
             _eventAggregator.Publish(new UserFeedbackMessage("You need to enter a search text."));
             break;
         case UserFeedback.InvalidLoginInfo:
             _eventAggregator.Publish(new UserFeedbackMessage("The login information you provided was incorrect."));
             break;
     }
 }
        public HttpResponseMessage PostSubmitFeedback(UserFeedback userFeedback)
        {
            if (userFeedback != null)
            {
                userFeedback.Description = userFeedback.Description.Replace("\n", "<br/>");

                Feedback feedback = new Feedback
                {
                    AddedByDeveloperID = userFeedback.AddedByDeveloperId,
                    AddedDate = DateTime.Now,
                    Description = userFeedback.Description,
                    ApplicationID = (byte?)userFeedback.ApplicationType
                };

                this.feedbackService.InsertOrUpdate(feedback);

                return Request.CreateResponse(HttpStatusCode.Created);
            }

            return Request.CreateResponse(HttpStatusCode.BadRequest);
        }
 public void AddUserFeedbackToPost(UserFeedback userFeedback)
 {
     throw new NotImplementedException();
 }
 public void Delete(UserFeedback userFeedback)
 {
     throw new NotImplementedException();
 }