public void Create(FeedbackDto feedback)
        {
            var newFeedback = new Feedback
            {
                Id          = Guid.NewGuid(),
                Description = feedback.Description,
                IdIntern    = feedback.IdIntern,
                IdMentor    = feedback.IdMentor,
                Rating      = feedback.Rating
            };

            _repository.Insert(newFeedback);
            _repository.Save();
        }
Exemplo n.º 2
0
        public async Task <FeedbackDto> CreateFeedbackAsync(FeedbackDto feedbackDto)
        {
            Feedback feedback = feedbackDto.ToEntity();

            feedback.Date = DateTime.Now;
            Feedback created = await _repository.AddFeedbackAsync(feedback);

            if (created == null)
            {
                throw new Exception("Feedback already exists.");
            }

            return(new FeedbackDto(created));
        }
Exemplo n.º 3
0
 public void FeedbackPost(
     [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "feedback")] FeedbackDto request,
     [SendGrid] out SendGridMessage message,
     ILogger log,
     ClaimsPrincipal principal
     )
 {
     message = new SendGridMessage();
     message.AddTo(Environment.GetEnvironmentVariable("FeedbackRecipient"));
     message.AddContent("text/html", request.Message);
     message.SetFrom(request.Email);
     message.SetSubject("Feedback for MaintenanceTracker");
     log.LogInformation($"Sending feedback message from anonymous user");
 }
Exemplo n.º 4
0
        public static Feedback FeedbackDtoToFeedback(FeedbackDto feedbackDto)
        {
            Feedback feedback = new Feedback
            {
                Id        = feedbackDto.Id,
                PatientId = feedbackDto.PatientId,
                Text      = feedbackDto.Text,
                Date      = feedbackDto.Date,
                IsDeleted = feedbackDto.IsDeleted,
                IsVisible = feedbackDto.IsVisible
            };

            return(feedback);
        }
Exemplo n.º 5
0
        public static FeedbackDto FeedbackToFeedbackDto(Feedback feedback)
        {
            FeedbackDto feedbackDto = new FeedbackDto
            {
                Id        = feedback.Id,
                PatientId = feedback.PatientId,
                Text      = feedback.Text,
                Date      = feedback.Date,
                IsDeleted = feedback.IsDeleted,
                IsVisible = feedback.IsVisible
            };

            return(feedbackDto);
        }
Exemplo n.º 6
0
        public void Start()
        {
            const string queryString      = "SELECT [ID],[Name],[Description] FROM [dbo].[Feedbacks] ORDER BY [ID] ASC";
            const string countString      = "SELECT COUNT([ID]) AS COUNT FROM [dbo].[Feedbacks]";
            const string connectionString = "Server=.;Database=TransactionManagement;User Id=stocktrading;Password=stocktrading;";

            //Load from db
            using (var connection = new SqlConnection(connectionString))
            {
                connection.Open();

                using (var command = new SqlCommand(countString, connection))
                {
                    var count = (int)command.ExecuteScalar();
                    LoggingService.Info($" ({count})");
                }

                using (var command = new SqlCommand(queryString, connection))
                {
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var item = new FeedbackDto();

                            item.OldId       = int.Parse(reader["ID"].ToString());
                            item.Name        = reader["Name"].ToString();
                            item.Description = reader["Description"].ToString();

                            Items.Add(item.OldId, item);
                        }
                    }
                }
            }

            //Import
            foreach (var item in Items)
            {
                var cmd = new FeedbackAddCommand(
                    item.Value.Id,
                    -1,
                    item.Value.Name,
                    item.Value.Description);

                CommandDispatcher.Execute(cmd);

                LoggingService.Info($"Feedback {item.Value.Name} ({item.Value.OldId})");
            }
        }
Exemplo n.º 7
0
        public void Create_ValidRequest_ShouldAddFeedback()
        {
            var feedback = new FeedbackDto
            {
                Rate       = 8,
                PageUrl    = _pageUrl,
                IsMainPage = _isMainPage,
                QuestionId = 1
            };

            var result = _repoitory.Create(_customerId, feedback);

            result.Should().Be(true);
            _mockFeedbacks.Should().HaveCount(1);
        }
Exemplo n.º 8
0
        [HttpPost]      // POST /api/feedback Request body: {"message": "Some message", "isPublic": true, "isAnonymous": false}
        public IActionResult Create(FeedbackDto dto)
        {
            // validation in feedback validator, automatically called from startup

            Feedback feedback = FeedbackService.Create(dto);

            if (feedback == null)
            {
                return(BadRequest());
            }
            else
            {
                return(Ok());
            }
        }
Exemplo n.º 9
0
        public FeedbackDto Add(FeedbackDto feedbackDto)
        {
            if (feedbackDto == null)
            {
                return(null);
            }

            Patient myPatient = _dbContext.Patients.SingleOrDefault(patient => patient.Id == feedbackDto.PatientId);

            RemovePreviousFeedback(feedbackDto, myPatient);

            _dbContext.Feedbacks.Add(FeedbackAdapter.FeedbackDtoToFeedback(feedbackDto));
            _dbContext.SaveChanges();

            return(feedbackDto);
        }
Exemplo n.º 10
0
        public void Analyze(List <JavaTestClass> referenceTests, List <JavaTestClass> studentTests, out FeedbackDto feedbackDto)
        {
            feedbackDto = new FeedbackDto();

            foreach (var referenceTest in referenceTests)
            {
                foreach (var referenceMethod in referenceTest.Methods)
                {
                    if (referenceMethod.LearningConcepts != null)
                    {
                        var instructorTestDto = GetInstructorTestDto(referenceMethod, studentTests);
                        feedbackDto.InstructorTests.Add(instructorTestDto);
                    }
                }
            }
        }
        public async Task <ActionResult <Feedback> > PostFeedback(FeedbackDto entry)
        {
            var profile = await GetLoggedInProfile();

            var feedback = _mapper.Map <Feedback>(entry);

            feedback.CreatedDate = DateTime.Now;
            feedback.ProfileId   = profile.Id;
            _context.Feedback.Add(feedback);
            await _context.SaveChangesAsync();

            feedback.Profile = profile;
            await SendEmail(feedback);

            return(CreatedAtAction("PostFeedback", new { id = entry.Id }, entry));
        }
Exemplo n.º 12
0
        public async Task SendFeedbackNotificationAsync(NotificationDto notification)
        {
            _logger.LogInformation($"Sending feedback notification...");
            EmailMessage emailMessage = await _transactionalMailHelper.PrepareFeedbackMail(notification);

            await _messageQueue.SendMessageAsync(emailMessage);

            // Send feedback to slack as well
            var feedback = new FeedbackDto()
            {
                Content = notification.Content
            };
            await _messageQueue.SendMessageAsync(feedback, "feedback", queueName : _pubSlackAppQueueName);

            return;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Routes to a dynamically generated "Feedback Show" Page. Gathers information from the database.
        /// </summary>
        /// <param name="id">Id of the Feedback</param>
        /// <returns>A dynamic "Feedback Show" webpage which provides detailes for a selected blog.</returns>
        /// <example>GET : /Feedback/Show/5</example>
        public ActionResult Show(int id)
        {
            ShowFeedbackViewModel ViewModel = new ShowFeedbackViewModel();
            string url = "feedbackapi/findfeedback/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                FeedbackDto SelectedFeedback = response.Content.ReadAsAsync <FeedbackDto>().Result;
                ViewModel.Feedback = SelectedFeedback;
                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Exemplo n.º 14
0
        public async Task <ResultDto> AddNewFeedback(FeedbackDto feedbackDto, string userId)
        {
            var feedback = new Feedback
            {
                User         = _context.Users.Where(u => u.UUID == userId).FirstOrDefault(),
                FeedbackBody = feedbackDto.FeedbackBody,
                CreatedAt    = DateTime.Now,
                UpdatedAt    = DateTime.Now,
                UUID         = Guid.NewGuid().ToString(),
                Anonymous    = feedbackDto.UserId.Length == 0
            };

            _context.Add(feedback);
            await _context.SaveChangesAsync();

            return(new ResultDto(true, "Feedback added succesfully"));
        }
        public async Task <IHttpActionResult> Feedback(int id, [FromBody] FeedbackDto dto)
        {
            var report = await _failureRepo.GetByIdAsync(id);

            if (report == null)
            {
                return(NotFound());
            }
            var user = await User.GetEntityAsync(_identityRepo);

            var feedback = Mapper.Map <FeedbackDto, Feedback>(dto);

            report.SetFeedBack(user, feedback);
            await _failureRepo.SaveAsync(report);

            return(StatusCode(HttpStatusCode.Accepted));
        }
        public async Task <ActionResult <FeedbackDto> > CreateFeedback([FromBody] FeedbackDto feedbackDto)
        {
            if (feedbackDto == null)
            {
                return(BadRequest("Feedback data must be set!"));
            }
            try
            {
                FeedbackDto created = await _service.CreateFeedbackAsync(feedbackDto);

                return(Ok(created));
            }
            catch (Exception e)
            {
                return(Conflict(e.Message));
            }
        }
Exemplo n.º 17
0
        public Feedback Add(FeedbackDto feedbackDto)
        {
            var feedback = new Feedback
            {
                Id          = Guid.NewGuid(),
                Body        = feedbackDto.Body,
                StudentId   = feedbackDto.StudentId,
                ProfessorId = feedbackDto.ProfessorId
            };

            _repository.Insert(feedback);
            _repository.Save();

            CreateNotification(feedback);

            return(feedback);
        }
Exemplo n.º 18
0
        public async Task <ActionResult <Feedback> > PostFeedback([FromBody] FeedbackDto feedbackDto)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var user   = await _userManager.FindByIdAsync(userId);

            var feedback = new Feedback
            {
                Content      = feedbackDto.Content,
                PostDateTime = DateTime.Now,
                RemoteIp     = HttpContext.Connection.RemoteIpAddress.ToString(),
                Username     = user.UserName
            };

            _context.Feedbacks.Add(feedback);
            await _context.SaveChangesAsync();

            return(Ok(feedback));
        }
Exemplo n.º 19
0
        public ActionResult Update(int id, FeedbackDto FeedbackInfo)
        {
            GetApplicationCookie();

            string      url     = "feedbackapi/updatefeedback/" + id;
            HttpContent content = new StringContent(jss.Serialize(FeedbackInfo));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Show", new { id }));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Exemplo n.º 20
0
        public int AddFeedback(FeedbackDto feedback)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@actualClassId",           feedback.ActualClass.Id),
                new SqlParameter("@usefulness",              feedback.Usefulness),
                new SqlParameter("@novelty",                 feedback.Novelty),
                new SqlParameter("@highScientificLevel",     feedback.HighScientificLevel),
                new SqlParameter("@rigorousScientificLevel", feedback.RigorousScientificLevel),
                new SqlParameter("@attractivenes",           feedback.Attractiveness),
                new SqlParameter("@clearness",               feedback.Clearness),
                new SqlParameter("@correctness",             feedback.Correctness),
                new SqlParameter("@interactivity",           feedback.Interactivity),
                new SqlParameter("@comprehension",           feedback.Comprehension),
                new SqlParameter("@comment",                 feedback.Comment)
            };

            return(DatabaseProvider.ExecuteCommand <int>(DatabaseProvider.GetSqlConnection(), ADD, CommandType.StoredProcedure, parameters));
        }
Exemplo n.º 21
0
        public async Task <ResultDto> UpdateFeedback(FeedbackDto feedbackDto, string userId)
        {
            var originalFeedback = await _context.Feedbacks
                                   .Where(f => f.UUID == feedbackDto.UUID && f.User.UUID == userId && f.Anonymous != true)
                                   .Include(f => f.User)
                                   .FirstOrDefaultAsync();

            if (originalFeedback == null)
            {
                return(new ResultDto(false, "Feedback not found"));
            }

            originalFeedback.UpdatedAt             = DateTime.Now;
            originalFeedback.FeedbackBody          = feedbackDto.FeedbackBody;
            _context.Entry(originalFeedback).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(new ResultDto(true, "Feedback updated succesfully"));
        }
Exemplo n.º 22
0
        public List <FeedbackDto> GetByProfId(Guid profId)
        {
            var feedback     = _repository.GetAllByFilter <Feedback>(x => x.ProfessorId == profId);
            var feedbackDtos = new List <FeedbackDto>();

            foreach (var value in feedback)
            {
                var feedbackDto = new FeedbackDto
                {
                    Body        = value.Body,
                    StudentId   = value.StudentId,
                    ProfessorId = value.ProfessorId
                };

                feedbackDtos.Add(feedbackDto);
            }

            return(feedbackDtos);
        }
        public OutMsg UpdateFeedbackDetail(int id, FeedbackDto feedbackDto)
        {
            if (feedbackDto == null)
            {
                throw new ArgumentNullException();
            }

            var message = new OutMsg {
                Status = false, Msg = "修改信息失败"
            };

            var currentFeedback = _feedbackRepository.Get(id);
            var updateFeedback  = QsMapper.CreateMap <FeedbackDto, Feedback>(feedbackDto);

            _feedbackRepository.Merge(currentFeedback, updateFeedback);
            _feedbackRepository.UnitOfWork.Commit();
            message.Msg    = "成功修改信息";
            message.Status = true;
            return(message);
        }
        public void Update(FeedbackDto feedback)
        {
            Feedback feedbackToUpdate = _repository.GetByFilter <Feedback>(p => p.IdIntern == feedback.IdIntern && p.IdMentor == feedback.IdMentor);

            if (feedbackToUpdate == null)
            {
                return;
            }

            if (feedback.Description != null)
            {
                feedbackToUpdate.Description = feedback.Description;
            }
            if (feedback.Rating != null)
            {
                feedbackToUpdate.Rating = feedback.Rating;
            }

            _repository.Update(feedbackToUpdate);
            _repository.Save();
        }
Exemplo n.º 25
0
        public async Task <IActionResult> SendFeedback([FromBody] FeedbackDto feedback)
        {
            ResponseDto <NotificationDto> okResponse    = new ResponseDto <NotificationDto>(true);
            ResponseDto <ErrorDto>        errorResponse = new ResponseDto <ErrorDto>(false);

            NotificationDto notification = new NotificationDto(feedback.Content);

            try
            {
                await _notifier.SendFeedbackNotificationAsync(notification);

                okResponse.Data = notification;
            }
            catch (Exception e)
            {
                errorResponse.Data = new ErrorDto(e.Message);
                return(BadRequest(errorResponse));
            }

            return(Ok(okResponse));
        }
Exemplo n.º 26
0
        public async Task <IActionResult> Create([FromBody] FeedbackDto feedbackDto)
        {
            var feedback       = Mapper.Map <Feedback>(feedbackDto);
            var candidateEmail = this.User.Identities.First().Name;

            var candidate = await _candidateRepository.GetSingleAsync(c => c.Email == candidateEmail);


            if (feedback.TestId == 0)
            {
                var test = await _testRepository.GetSingleAsync(t => t.Candidate.Email == candidateEmail);

                feedback.TestId = test != null ? test.Id : 0;
            }

            feedback.CandidateId = candidate.Id;
            _feedbackRepository.Add(feedback);
            _feedbackRepository.Commit();

            return(Created(string.Empty, feedback));
        }
Exemplo n.º 27
0
        public IList <FeedbackDto> GetAllFeedbacksForActualClass(int classId)
        {
            IList <FeedbackDto> feedbacks = new List <FeedbackDto>();

            using (SqlConnection connection = DatabaseProvider.GetSqlConnection())
            {
                SqlParameter[] parameters = { new SqlParameter("@actualClassId", classId) };

                using (IDataReader reader =
                           DatabaseProvider.ExecuteCommand <IDataReader>(connection, GETFEEDBACKS, CommandType.StoredProcedure, parameters))
                {
                    while (reader.Read())
                    {
                        FeedbackDto fb = DtoHelper.GetDto <FeedbackDto>(reader);
                        feedbacks.Add(fb);
                    }
                }
            }

            return(feedbacks);
        }
Exemplo n.º 28
0
        public async Task <IActionResult> SubmitFeedback([FromForm] FeedbackDto feedbackDto)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index"));
            }
            if (feedbackDto.Anonymous)
            {
                feedbackDto.Name  = null;
                feedbackDto.Email = null;
            }
            var feedback = new Feedback(feedbackDto);

            _context.Add(feedback);
            await _context.SaveChangesAsync();

            var hooks = await _context.Webhooks.Where(w => w.FeedbackType == feedback.Type).ToListAsync();

            using (var client = new HttpClient())
            {
                foreach (var hook in hooks)
                {
                    var data = new StringContent(JsonConvert.SerializeObject(feedback), Encoding.UTF8, "application/json");
                    try
                    {
                        _logger.LogInformation(
                            $"Notifying '{hook.CallbackUrl}' with type = {feedback.Type}," + $"anonymous = {feedback.Anonymous}, " +
                            $"name = {feedback.Name}, email = {feedback.Email}");
                        var result = await client.PostAsync(hook.CallbackUrl, data);

                        _logger.LogInformation($"Notification result: {result.StatusCode}");
                    }
                    catch (HttpRequestException e)
                    {
                        _logger.LogError($"Failed to notify {hook.CallbackUrl}:\n{e.Message}");
                    }
                }
            }
            return(RedirectToAction("Index", "Feedback"));
        }
Exemplo n.º 29
0
        public async Task <IActionResult> PostFeedBack(FeedbackDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            try
            {
                var feedback = new Feedback()
                {
                    Comment = model.Comment,
                    UserId  = model.UserId,
                    SpotId  = model.SpotId
                };

                return(Ok(_feedBackBusiness.PostFeedBack(feedback)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message)); // return BadRequest(ex.Message);
            }
        }
Exemplo n.º 30
0
        public IHttpActionResult FindFeedback(int id)
        {
            FeedbackModel Feedback = db.Feedback.Find(id);

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

            FeedbackDto FeedbackDto = new FeedbackDto
            {
                feedback_id = Feedback.feedback_id,
                date        = Feedback.date,
                fname       = Feedback.fname,
                lname       = Feedback.lname,
                email       = Feedback.email,
                title       = Feedback.title,
                text        = Feedback.text
            };

            return(Ok(FeedbackDto));
        }