Beispiel #1
0
        public List <DisputeViewModel> GetUnresolvedDisputes()
        {
            AppDbContext db = new AppDbContext();

            List <Dispute> disputeList = new List <Dispute>();
            var            query       = from d in db.Disputes
                                         select d;

            query       = query.Where(d => d.DisputeStatus == DisputeStatus.Submitted);
            disputeList = query.ToList();

            List <DisputeViewModel> dvmList = new List <DisputeViewModel>();

            foreach (Dispute d in disputeList)
            {
                DisputeViewModel dvm = new DisputeViewModel();
                dvm.CorrectAmount = d.DisputedAmount;
                dvm.FirstName     = d.AppUser.FirstName;
                dvm.LastName      = d.AppUser.LastName;
                dvm.TransAmount   = d.Transaction.Amount;
                dvm.Message       = d.Message;
                dvm.CustEmail     = d.AppUser.Email;
                dvm.TransName     = d.Transaction.TransactionID;
                dvm.DisputeID     = d.DisputeID;
                dvm.Status        = DisputeStatus.Submitted;
                dvmList.Add(dvm);
            }


            return(dvmList);
        }
        public ActionResult Create(DisputeViewModel viewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ViewBag.Error = "Please check the entered values. ";
                    return(View(viewModel));
                }

                var terminal = _TerminalRepository.GetTerminal(viewModel.TerminalId);

                viewModel.IndexId    = terminal.Id;
                viewModel.TerminalId = terminal.TerminalId;

                if (viewModel.IndexId > 0)
                {
                    _DisputeRepository.DisputeAdd(viewModel);
                }
                else
                {
                    ViewBag.Error = "Terminal not found";
                    return(View(viewModel));
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Validation error Create Dispute, "
                                + ex.Message;
                return(View(viewModel));
            }
        }
        public ActionResult Edit(DisputeViewModel viewModel)
        {
            try
            {
                //    viewModel.Terminal.TerminalAlertConfigs = null;
                //        viewModel.Terminal = _TerminalRepository.GetTerminal(viewModel.Terminal.TerminalId);
                _DisputeRepository.DisputeUpdate(viewModel);

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void DisputeAdd(DisputeViewModel viewModel)
        {
            try
            {
                //var dispute = new Dispute() { IndexId = viewModel.Terminal.Id };
                var dispute = Mapper.Map <DisputeViewModel, Dispute>(viewModel);

                Table.Add(dispute);
                Save();
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ActionResult Details(Guid id)
        {
            var dispute = _context.Disputes
                          .Include(d => d.Audit.Auditee)
                          .Include(d => d.Audit.AuditTemplate)
                          .Include(d => d.Audit.Supervisor)
                          .Include(d => d.Decision)
                          .Include(d => d.Decider)
                          .Single(d => d.AuditId == id);
            var viewModel = new DisputeViewModel();

            AutoMapper.Mapper.Map(dispute, viewModel);

            viewModel.DecisionOptions = _context.DisputeDecisions.ToList();

            return(View(viewModel));
        }
        public DisputeViewModel GetDispute(int id)
        {
            try
            {
                var dispute = Table.Include("Terminal").Include("DisputeRepresent").FirstOrDefault(m => m.Id == id);

                var viewModel = new DisputeViewModel();

                viewModel = Mapper.Map <Dispute, DisputeViewModel>(dispute);

                return(viewModel);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void DisputeUpdate(DisputeViewModel viewModel)
        {
            try
            {
                var dispute = new Dispute()
                {
                    IndexId = viewModel.Terminal.Id
                };

                dispute = Mapper.Map <DisputeViewModel, Dispute>(viewModel);

                Edit(dispute);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public DisputeViewModel GetTerminalTransaction(string terminalId)
        {
            //pendiente pasarle por parametro el secuencialnumber
            var url         = "http://apiatm.azurewebsites.net/api/request/transactions/" + "NH061617" + "/" + "0088";
            var json        = new WebClient().DownloadString(url);
            var transaction = JsonConvert.DeserializeObject <List <Transaction> >(json);


            if (transaction.Count() > 0)
            {
                var viewModel = new DisputeViewModel()
                {
                    TerminalId     = transaction.FirstOrDefault().TerminalId,
                    SecuenceNumber = transaction.FirstOrDefault().SequenceNumber,
                    TransacNo      = transaction.FirstOrDefault().Id,
                };
                return(viewModel);
            }
            else
            {
                return(new DisputeViewModel());
            }
        }
        public ActionResult Details(DisputeViewModel model)
        {
            var userId         = User.Identity.GetUserId();
            var user           = _context.Users.Single(u => u.Id == userId);
            var submitDateTime = DateTime.Now;
            var dispute        = _context.Disputes.Single(d => d.AuditId == model.AuditId);

            if (dispute.DecisionId != model.DecisionId)
            {
                dispute.DecisionId = model.DecisionId;
                if (dispute.DecisionId != null)
                {
                    var decision = _context.DisputeDecisions.Single(d => d.Id == dispute.DecisionId);
                    dispute.DecisionDateTime = submitDateTime;
                    dispute.DeciderId        = userId;
                    dispute.Comments         = $"{user.NameFLUser} {submitDateTime.ToString("MM/dd/yyyy hh:mm:ss tt")}\r\n" +
                                               "Updated decision to " + decision.Text + "\r\n\r\n" + dispute.Comments;
                }
                else
                {
                    dispute.DecisionDateTime = null;
                    dispute.DeciderId        = userId;
                    dispute.Comments         = $"{user.NameFLUser} {submitDateTime.ToString("MM/dd/yyyy hh:mm:ss tt")}\r\n" +
                                               "Removed decision.  Dispute now pending deicision" + "\r\n\r\n" + dispute.Comments;
                }
            }
            if (!string.IsNullOrWhiteSpace(model.NewComment))
            {
                dispute.Comments = $"{user.NameFLUser} {submitDateTime.ToString("MM/dd/yyyy hh:mm:ss tt")}\r\n" +
                                   model.NewComment + "\r\n\r\n" + dispute.Comments;
            }

            _context.SaveChanges();

            return(RedirectToAction("Details", new { id = dispute.AuditId }));
        }