Пример #1
0
        public void AcceptDispute(ComplaintStatus status)
        {
            var service   = new ComplaintService(_tolkDbContext, _clock, _notificationService, _logger);
            var complaint = new Complaint
            {
                Status = status
            };

            service.AcceptDispute(complaint, 1, null, "detta är ok");
        }
Пример #2
0
        public void AcceptDispute_InvalidStatus(ComplaintStatus status)
        {
            var service   = new ComplaintService(_tolkDbContext, _clock, _notificationService, _logger);
            var complaint = new Complaint
            {
                Status = status
            };

            Assert.Throws <InvalidOperationException>(() =>
                                                      service.AcceptDispute(complaint, 1, null, "får inte acceptera"));
        }
        public async Task <IActionResult> AcceptDispute(AnswerDisputeComplaintModel model)
        {
            var complaint = await _dbContext.Complaints.GetFullComplaintById(model.ComplaintId);

            if (ModelState.IsValid)
            {
                if ((await _authorizationService.AuthorizeAsync(User, complaint, Policies.Accept)).Succeeded)
                {
                    if (!complaint.CanAnswerDispute)
                    {
                        _logger.LogWarning("Wrong status when trying to Accept Dispute complaint. Status: {complaint.Status}, ComplaintId: {complaint.ComplaintId}", complaint.Status, complaint.ComplaintId);
                        return(RedirectToAction("View", "Request", new { id = complaint.RequestId, tab = "complaint" }));
                    }

                    _complaintService.AcceptDispute(complaint, User.GetUserId(), User.TryGetImpersonatorId(), model.AnswerDisputedMessage);
                    await _dbContext.SaveChangesAsync();

                    return(RedirectToAction("View", "Order", new { id = complaint.Request.OrderId, tab = "complaint" }));
                }
                return(Forbid());
            }
            return(RedirectToAction("View", "Order", new { id = complaint.Request.OrderId, tab = "complaint" }));
        }