示例#1
0
        public async Task <IActionResult> SendMessage(FeedbackViewModel feedbackViewModel)
        {
            SendFeedbackViewModel details = new SendFeedbackViewModel();
            var contact = _contactService.LoadContactDetail();

            details.Contact = contact;

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError(string.Empty, string.Empty);
                return(View("Index", details));
            }
            _feedbackService.AddFeedback(feedbackViewModel);
            _feedbackService.Save();

            var flag = HttpContext.Session.Get <FlagIndicate>(Flag.Contact);

            if (flag == null)
            {
                flag         = new FlagIndicate();
                flag.Content = Flag.Contact;
                HttpContext.Session.Set <FlagIndicate>(Flag.Contact, flag);
            }

            await _emailSender.SendFeedback(CommonConstants.mailAdmin, feedbackViewModel);

            return(RedirectToAction("Index", "Contact"));
        }
示例#2
0
        public async Task <IActionResult> AddFeedback([FromBody] FeedbackViewModel feedback)
        {
            if (!ModelState.IsValid)
            {
                return(new BadResponseResult(ModelState));
            }

            FeedbackEntity feedbackDb = new FeedbackEntity {
                UserId = feedback.UserId, FeedbackType = feedback.FeedbackType, Text = feedback.Text, AddedDate = DateTime.UtcNow
            };

            if (!await _feedbackService.AddFeedback(feedbackDb))
            {
                return(new ResponseResult((int)HttpStatusCode.InternalServerError, "We can not add your feedback."));
            }
            return(new OkResponseResult("We add your feedback."));
        }
 public IActionResult Feedback(FeedbackViewModel feedback)
 {
     if (ModelState.IsValid)
     {
         _feedbackService.AddFeedback(feedback.FeedbackDetails);
         return(RedirectToAction("FeedbackComplete"));
     }
     return(View(feedback));
 }
        public IActionResult AddFeedback([FromBody] FeedbackDto feedbackDto)
        {
            if (ModelState.IsValid)
            {
                _feedbackService.AddFeedback(feedbackDto);
                return(StatusCode(StatusCodes.Status201Created));
            }

            return(BadRequest());
        }
        public async Task <ActionResult> CreateFeedback([FromBody] FeedbackModel feedbackModel)
        {
            FeedbackDTO feedbackDTO = new FeedbackDTO
            {
                Id           = feedbackModel.Id,
                Content      = feedbackModel.Content,
                CreationDate = DateTime.Now,
                UserId       = feedbackModel.UserId,
                UserName     = feedbackModel.UserName,
                TourId       = feedbackModel.TourId
            };
            var operationDetails = await _feedbackService.AddFeedback(feedbackDTO);

            Log.Information($"Feedback {feedbackDTO.Id} is added succesfully");
            return(Ok(operationDetails));
        }
示例#6
0
 public DemoMutation(IFeedbackService feedbackService)
 {
     Name = "Mutation";
     Field <FeedbackType>(
         "addFeedback",
         description: "Submit feedback to the application",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StringGraphType> > {
         Name = "text"
     }),
         resolve: context =>
     {
         var feedbackInput = context.GetArgument <string>("text");
         return(feedbackService.AddFeedback(new Feedback(Guid.NewGuid().ToString(), feedbackInput)));
     }
         );
 }
示例#7
0
        public async Task <HttpResponseMessage> Create()
        {
            HttpRequest httpRequest          = HttpContext.Current.Request;
            string      id                   = httpRequest.Params["id"];
            string      category             = httpRequest.Params["category"];
            string      type                 = httpRequest.Params["type"];
            string      description          = httpRequest.Params["description"];
            string      fileName             = httpRequest.Params["fileName"];
            string      notificationOfStatus = httpRequest.Params["notificationOfStatus"];
            string      route                = httpRequest.Params["link"];
            string      url                  = LocalUrlHelper.GetApplicationUrl() + route;

            if (description == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Not all params are defined"));
            }

            Feedback feedback = new Feedback
            {
                Id                   = id.HasValue() ? new Guid(id) : Guid.Empty,
                Type                 = (FeedbackType)Enum.Parse(typeof(FeedbackType), type, true),
                Category             = (FeedbackCategory)Int32.Parse(category),
                Description          = description,
                FileName             = fileName.HasValue() ? fileName : null,
                NotificationOfStatus = notificationOfStatus != "undefined" && bool.Parse(notificationOfStatus),
                Url                  = url
            };

            ServiceResult result = await _feedbackService.AddFeedback(feedback, httpRequest.Files.Count > 0?httpRequest.Files[0].InputStream : null);

            if (result.Succeeded)
            {
                result = _feedbackService.Notify(feedback);
            }

            return(result.Succeeded
                ? Request.CreateResponse(HttpStatusCode.OK)
                : Request.CreateErrorResponse(HttpStatusCode.BadRequest, result.Message));
        }
        public ActionResult Create(FeedbackCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var recentFeedback = _feedbackService.GetActiveItem();

            if (recentFeedback == null || recentFeedback.Status == EnumFbStatus.Closed)
            {
                var feedbackDto = new FeedbackDto
                {
                    FeedbackName = model.Title,
                    StartTime    = model.StartTime == null ? DateTime.Now : (DateTime)model.StartTime,
                    EndTime      = model.EndTime == null ? DateTime.Now : (DateTime)model.EndTime
                };

                feedbackDto.JudgeStatus();
                _feedbackService.AddFeedback(feedbackDto);
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public async Task <HttpResponseMessage> PostFeedback(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "Deliveries/{id}/Feedback")] HttpRequest req, string id)
        {
            string token = req.Headers["Authorization"].ToString().Replace("Bearer ", "");

            if (_authorizationsService.IsTokenValid(token, true))
            {
                StreamReader r           = new StreamReader(req.Body);
                string       requestBody = await r.ReadToEndAsync();

                r.Dispose(); // Dispose StreamReader so it cannot be used anymore
                List <Feedback> feedback = JsonConvert.DeserializeObject <List <Feedback> >(requestBody);
                List <Feedback> result   = await _feedbackService.AddFeedback(feedback);

                return(result != null
                    ? new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(JsonConvert.SerializeObject(result), Encoding.UTF8, "application/json")
                }
                    : new HttpResponseMessage(HttpStatusCode.BadRequest));
            }
            // Authorized access only
            return(new HttpResponseMessage(HttpStatusCode.Unauthorized));
        }
示例#10
0
        public FeedbackForDetailed AddFeedback(FeedbackForInsert feedback)
        {
            var userId = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            return(_service.AddFeedback(feedback, userId));
        }