public ActionResult Details(int id)
        {
            if (Session["login"] == null)
            {
                return(RedirectToAction("index", "login"));
            }
            string [] responsePayment = new string[3];
            ordersDTO ordersDto       = _ordersDomainService.GetById(id);

            if (ordersDto == null || ordersDto.user_email != (string)Session["login"])
            {
                return(HttpNotFound());
            }
            if (ordersDto.status == "CREATED")
            {
                paymentProcess p = new paymentProcess();
                responsePayment = p.statusRequest(ordersDto.transaction_id);
                switch (responsePayment[0])
                {
                case "APPROVED":
                    ordersDto.status = "PAYED"; break;

                case "REJECTED":
                    ordersDto.status = "REJECTED"; break;
                }

                ordersDto.paymentStatus = responsePayment[0];
                _ordersDomainService.update(ordersDto);
            }

            return(View(ordersDto));
        }
        public ActionResult prePay(int id)
        {
            if (Session["login"] == null)
            {
                return(RedirectToAction("index", "login"));
            }
            ordersDTO ordersDto = _ordersDomainService.GetById(id);

            if (ordersDto == null || ordersDto.user_email != (string)Session["login"])
            {
                return(HttpNotFound());
            }
            switch (ordersDto.status)
            {
            case "PAYED": return(RedirectToAction("Details/" + id));

            case "REJECTED":
                ordersDto.status     = "CREATED";
                ordersDto.updated_at = DateTime.Now;
                _ordersDomainService.update(ordersDto);
                break;

            default:
                if (ordersDto.paymentStatus == "PENDING")
                {
                    return(RedirectToAction("Details/" + id));
                }
                break;
            }

            return(View(ordersDto));
        }
        public ActionResult Create([Bind(Include = "id,status,customer_name,customer_email,customer_mobile,status,created_at,updated_at,price")] ordersDTO ordersDto)
        {
            if (Session["login"] == null)
            {
                return(RedirectToAction("index", "login"));
            }
            ordersDto.status     = "CREATED";
            ordersDto.created_at = DateTime.Now;
            ordersDto.updated_at = DateTime.Now;
            ordersDto.user_email = (string)Session["login"];
            if (ModelState.IsValid)
            {
                ordersDto = _ordersDomainService.Create(ordersDto);
                return(RedirectToAction("prePay/" + ordersDto.id));
            }

            return(View(ordersDto));
        }
示例#4
0
        public static orders Map(this ordersDTO dto)
        {
            var order = new orders()
            {
                id              = dto.id,
                customer_name   = dto.customer_name,
                customer_email  = dto.customer_email,
                customer_mobile = dto.customer_mobile,
                created_at      = dto.created_at,
                updated_at      = dto.updated_at,
                status          = dto.status,
                price           = dto.price,
                transaction_id  = dto.transaction_id,
                user_email      = dto.user_email,
                url_payment     = dto.url_payment,
                paymentStatus   = dto.paymentStatus,
            };

            return(order);
        }
示例#5
0
        public static ordersDTO Map(this orders entity)
        {
            var dto = new ordersDTO()

            {
                id              = entity.id,
                customer_name   = entity.customer_name,
                customer_email  = entity.customer_email,
                customer_mobile = entity.customer_mobile,
                created_at      = entity.created_at,
                updated_at      = entity.updated_at,
                status          = entity.status,
                price           = entity.price,
                transaction_id  = entity.transaction_id,
                user_email      = entity.user_email,
                url_payment     = entity.url_payment,
                paymentStatus   = entity.paymentStatus,
            };

            return(dto);
        }
        public ActionResult prePay([Bind(Include = "id,status,customer_name,user_email,customer_email,customer_mobile,price,updated_at,created_at")] ordersDTO ordersDto)
        {
            if (Session["login"] == null)
            {
                return(RedirectToAction("index", "login"));
            }
            paymentProcess p = new paymentProcess();

            string [] responsePaymentService = new string[3];

            if (ModelState.IsValid)
            {
                responsePaymentService = p.CreatePayment("PRODCTO DE EJEMPLO", "Compra de producto de ejemplo con valor  Fijo", ordersDto.price, Request.UserHostAddress, ordersDto.customer_name, ordersDto.id.ToString());
                if (responsePaymentService[3] == "OK")
                {
                    ordersDto.transaction_id = responsePaymentService[1];
                    ordersDto.url_payment    = responsePaymentService[2];
                    ordersDto.updated_at     = DateTime.Now;
                    _ordersDomainService.update(ordersDto);
                    return(Redirect(responsePaymentService[2]));
                }
            }
            return(View(ordersDto));
        }
示例#7
0
 public ordersDTO update(ordersDTO order)
 {
     _ordersRepository.update(order.Map());
     return(order);
 }
示例#8
0
 public ordersDTO Create(ordersDTO order)
 {
     order = _ordersRepository.Create(order.Map()).Map();
     return(order);
 }