Beispiel #1
0
        public JsonResult GiveFeedback(GiveFeedbackViewModel model)
        {
            if (model.ReceiverId != null && ModelState.IsValid && Enum.IsDefined(typeof(Emotions), model.Grade))
            {
                if (model.Comment.Trim() == "")
                {
                    return(null);
                }
                if (model.OrderId != null)
                {
                    Order order = _orderService.GetOrder(model.OrderId.Value, i => i.Seller, i => i.Buyer, i => i.Feedbacks,
                                                         i => i.Seller.FeedbacksMy, i => i.Buyer.FeedbacksMy, i => i.Seller.FeedbacksToOthers, i => i.Buyer.FeedbacksToOthers);

                    if (order != null && order.BuyerId == model.ReceiverId && order.SellerId == User.Identity.GetUserId() && !order.SellerFeedbacked)
                    {
                        order.SellerFeedbacked = true;
                        var feedback = Mapper.Map <GiveFeedbackViewModel, Feedback>(model);

                        if (feedback.Grade == Emotions.Good)
                        {
                            order.Buyer.PositiveFeedbackCount++;
                        }
                        else if (feedback.Grade == Emotions.Bad)
                        {
                            order.Buyer.NegativeFeedbackCount++;
                        }

                        order.Feedbacks.Add(feedback);
                        order.Buyer.FeedbacksMy.Add(feedback);
                        order.Seller.FeedbacksToOthers.Add(feedback);
                        _feedbackService.CreateFeedback(feedback);
                        _feedbackService.SaveFeedback();
                        return(Json(new { }));
                    }
                    else if (order != null && order.Seller.Id == model.ReceiverId && order.BuyerId == User.Identity.GetUserId() && !order.BuyerFeedbacked)
                    {
                        order.BuyerFeedbacked = true;
                        var feedback = Mapper.Map <GiveFeedbackViewModel, Feedback>(model);

                        if (feedback.Grade == Emotions.Good)
                        {
                            order.Seller.PositiveFeedbackCount++;
                        }
                        else if (feedback.Grade == Emotions.Bad)
                        {
                            order.Seller.NegativeFeedbackCount++;
                        }
                        order.Feedbacks.Add(feedback);
                        order.Seller.FeedbacksMy.Add(feedback);
                        order.Buyer.FeedbacksToOthers.Add(feedback);
                        _feedbackService.CreateFeedback(feedback);
                        _feedbackService.SaveFeedback();
                        return(Json(new { }));
                    }
                }
            }
            return(null);
        }
 public IActionResult CreateFeedbackPost(FeedbackViewModel feedbackViewModel)
 {
     try
     {
         _feedbackService.CreateFeedback(feedbackViewModel);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         return(View("ExceptionView"));
     }
 }
 public IActionResult Create(FeedbackViewModel feedbackViewModel)
 {
     try
     {
         _feedbackService.CreateFeedback(feedbackViewModel);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         ViewBag.Message = e.Message;
         return(View("ExceptionPage"));
     }
 }
        public async Task <IActionResult> InsertFeedback(FeedbackViewModel feedbackViewModel)
        {
            Feedbacks feedback = feedbackViewModel.feedbackDto;

            feedback.PromotionId = 2;
            feedback.ClaimId     = 3;
            feedback.CreatedTime = DateTime.Now;
            feedback.IsDeleted   = false;
            feedback.CustomerId  = 2;
            int result = await _feedbackService.CreateFeedback(feedback);

            return(View("SuccessFeedbackClick", feedbackViewModel));
        }
        public IActionResult Post(PostFeedbackDTO postFeedbackDTO)
        {
            if (postFeedbackDTO.AdditionalNotes.Length <= 0)
            {
                return(BadRequest("Failed to post feedback"));
            }

            postFeedbackDTO.UserId = User.Identity.Name;
            Domain.Entities.Feedback feedbackSuccessfullyCreated = _feedbackService.CreateFeedback(postFeedbackDTO.UserId, postFeedbackDTO.AdditionalNotes, postFeedbackDTO.Anonymous, postFeedbackDTO.AllowedForPublishing);


            if (feedbackSuccessfullyCreated == null)
            {
                return(BadRequest("Failed to post feedback"));
            }
            return(Ok("Feedback posted successfully"));
        }
Beispiel #6
0
        public ApiResult Complaint([FromBody] CreateFeedbackModel feedback)
        {
            Argument.ThrowIfNullOrEmpty(feedback.Content, "投诉内容");
            if (feedback.OrderId.Equals(Guid.Empty))
            {
                throw new WebApiInnerException("0001", "订单Id不合法");
            }
            if (feedback.Content.Length > 900)
            {
                throw new WebApiInnerException("0002", "投诉内容太长");
            }

            var order = _currencyService.GetSingleById <Order>(feedback.OrderId);

            if (order == null)
            {
                throw new WebApiInnerException("0003", "订单不存在");
            }
            if (order.OrderStatus != OrderStatus.Completed)
            {
                throw new WebApiInnerException("0004", "订单未完成,不可以投诉");
            }
            if (!order.MemberId.Equals(AuthorizedUser.Id))
            {
                throw new WebApiInnerException("0005", "只能投诉自己的订单");
            }


            var model = new Feedback.Models.Feedback()
            {
                Content      = $"单号:{order.OrderNo},{feedback.Content}",
                FeedbackType = FeedbackType.Complaint,
                SourceId     = feedback.OrderId,
                SourceType   = "Order",
                MemberId     = AuthorizedUser.Id.ToGuid(),
                ModuleKey    = OrderProcessModule.Key,
                ModuleName   = OrderProcessModule.DisplayName
            };

            _feedbackService.CreateFeedback(model, feedback.ImageFiles);

            ApiResult result = new ApiResult();

            return(result);
        }
Beispiel #7
0
 public IActionResult CreateFeedback(FeedbackViewModel feedbackViewModel)
 {
     try
     {
         if (_feedbackService.FeedbackNumberValidation(feedbackViewModel.Email))
         {
             _feedbackService.CreateFeedback(feedbackViewModel);
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View("MaxFeedbacksReached"));
         }
     }
     catch (Exception e)
     {
         return(View("ExceptionView"));
     }
 }
        public ApiResult Create([FromBody] CreateFeedbackModel feedback)
        {
            Argument.ThrowIfNullOrEmpty(feedback.Content, "反馈内容");

            var model = new Models.Feedback()
            {
                Content      = feedback.Content,
                FeedbackType = feedback.FeedbackType,
                SourceType   = SourceTpye,
                MemberId     = AuthorizedUser.Id.ToGuid(),
                ModuleKey    = FeedbackModule.Key,
                ModuleName   = FeedbackModule.DisplayName
            };

            _feedbackService.CreateFeedback(model);

            ApiResult result = new ApiResult();

            return(result);
        }
        public async Task <IActionResult> CreateFeedback(CreateFeedbackRequest request)
        {
            await _feedbackService.CreateFeedback(request);

            return(StatusCode(StatusCodes.Status201Created));
        }
Beispiel #10
0
        public ActionResult Post(FeedbackViewModel feedBack, IFormCollection collection, IFormFile upload)
        {
            int i = 3;

            if (ModelState.IsValid)
            {
                List <FeedbackValue> FeedBackValues = new List <FeedbackValue>();
                var form = formService.GetForm((long)feedBack.FormId);
                foreach (var item in formService.GetFormFieldsByFormId((long)feedBack.FormId))
                {
                    var feedBackValue = new FeedbackValue();
                    feedBackValue.FormFieldName = item.Name;
                    feedBackValue.FieldType     = item.FieldType;
                    feedBackValue.FormFieldId   = (int)item.Id;
                    feedBackValue.Position      = item.Position;
                    feedBackValue.Value         = item.Value;
                    feedBackValue.AddedBy       = User.Identity.Name ?? "username";
                    feedBackValue.AddedDate     = DateTime.Now;
                    feedBackValue.ModifiedBy    = User.Identity.Name ?? "username";
                    feedBackValue.ModifiedDate  = DateTime.Now;

                    if (item.FieldType.ToString() == "multipleChoice" || item.FieldType.ToString() == "radioButtons" || item.FieldType.ToString() == "singleChoice")
                    {
                        feedBackValue.Value = "";
                        var choices = item.Value.Split(',');
                        foreach (var choice in choices)
                        {
                            if (i < collection.Count && choice == collection[i.ToString()])
                            {
                                feedBackValue.Value += "(+)" + collection[i.ToString()] + ",";
                                i++;
                            }
                            else if (i < collection.Count)
                            {
                                feedBackValue.Value += choice.ToString() + ",";
                            }
                        }
                        feedBackValue.Value = feedBackValue.Value.Remove(feedBackValue.Value.Length - 1);
                    }
                    else if (item.FieldType.ToString() == "file")
                    {
                        string FilePath    = ViewBag.UploadPath + "\\feedback\\";
                        string dosyaYolu   = Path.GetFileName(upload.FileName);
                        var    yuklemeYeri = Path.Combine(FilePath + dosyaYolu);
                        try
                        {
                            if (!Directory.Exists(FilePath))
                            {
                                Directory.CreateDirectory(FilePath);//Eğer klasör yoksa oluştur
                                upload.CopyTo(new FileStream(yuklemeYeri, FileMode.Create));
                            }
                            else
                            {
                                upload.CopyTo(new FileStream(yuklemeYeri, FileMode.Create));
                            }
                        }
                        catch (Exception) { }
                    }
                    else
                    {
                        if (i < collection.Count)
                        {
                            //feedBackValue.Value = collection[i.ToString()];
                            i++;
                        }
                    }
                    FeedBackValues.Add(feedBackValue);
                }

                //feedBack.IP = GetUserIP();  // gönderen ip method u eklenecek

                feedBack.SentDate = DateTime.Now;
                if (User.Identity.Name != null)
                {
                    feedBack.UserName = User.Identity.Name;
                }
                feedBack.FormName = form.FormName;
                var      remoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress;
                Feedback feed_back       = new Feedback();
                feed_back.Id             = feedBack.Id;
                feed_back.FormId         = feedBack.FormId;
                feed_back.FormName       = feedBack.FormName;
                feed_back.FeedbackValues = feedBack.FeedbackValues;
                feed_back.IP             = remoteIpAddress.ToString();
                feed_back.SentDate       = DateTime.Now;

                feed_back.UserName       = User.Identity.Name ?? "username";
                feed_back.AddedBy        = User.Identity.Name ?? "username";
                feed_back.AddedDate      = DateTime.Now;
                feed_back.ModifiedDate   = DateTime.Now;
                feed_back.ModifiedBy     = User.Identity.Name ?? "username";
                feed_back.FeedbackValues = FeedBackValues;

                feedbackService.CreateFeedback(feed_back);
                feedbackService.SaveFeedback();

                var userName = feedBack.UserName;
                var formId   = feedBack.FormId;

                // MESAJ GÖNDERİMİ BURAYA GELECEK
                if (form.EmailBcc != null || form.EmailCc != null || form.EmailTo != null)
                {
                    var message = new MimeMessage();
                    if (form.EmailCc != null)
                    {
                        var email_cc_list = form.EmailCc.Split(',');
                        foreach (var item2 in email_cc_list)
                        {
                            message.Cc.Add(new MailboxAddress(item2.Trim(), item2.Trim()));
                        }
                    }
                    if (form.EmailBcc != null)
                    {
                        var email_bcc_list = form.EmailBcc.Split(',');
                        foreach (var item2 in email_bcc_list)
                        {
                            message.Bcc.Add(new MailboxAddress(item2.Trim(), item2.Trim()));
                        }
                    }
                    if (form.EmailTo != null)
                    {
                        var email_to_list = form.EmailTo.Split(',');
                        foreach (var item2 in email_to_list)
                        {
                            message.To.Add(new MailboxAddress(item2.Trim(), item2.Trim()));
                        }
                    }
                    message.From.Add(new MailboxAddress("CMS Core", settingService.GetSettingByName("Email").Value));
                    var bodyBuilder = new BodyBuilder();
                    message.Subject = "CMS Core " + feedBack.FormName;
                    foreach (var item in feed_back.FeedbackValues)
                    {
                        //message.Body += EmailString(item).ToString() + "<br/>";
                        bodyBuilder.HtmlBody += EmailString(item);
                    }
                    message.Body = bodyBuilder.ToMessageBody();
                    try
                    {
                        using (var client = new SmtpClient())
                        {
                            client.Connect("smtp.gmail.com", 587, false);
                            client.AuthenticationMechanisms.Remove("XOAUTH2");
                            // Note: since we don't have an OAuth2 token, disable   // the XOAUTH2 authentication mechanism.
                            client.Authenticate(settingService.GetSettingByName("Email").Value, settingService.GetSettingByName("EmailPassword").Value);
                            client.Send(message);
                            client.Disconnect(true);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                return(RedirectToAction("Posted", "Feedback", new { id = formId }));
            }


            return(RedirectToAction("Index", "Feedback"));
        }