Esempio n. 1
0
        public ActionResult BuyService(BuyRequest request)
        {
            var service = paymentServices.CreateNewService(
                request.DefinitionId,
                request.Data.ToObjectDictionary()
                );

            if (IsCurrentUserAdmin())
            {
                var serviceDefinitionToActivate = dbContext.Services.Find(request.DefinitionId);
                service.Activate(serviceDefinitionToActivate);

                return(Redirect(Request.Headers["Referer"].ToString()));
            }

            string redirectUrl = string.Empty;

            try
            {
                redirectUrl = orders.Create(
                    request.DefinitionId,
                    service.Id,
                    currentUserProvider.UserId,
                    Request.HttpContext.Connection.RemoteIpAddress.ToString(),
                    "/Payment/Notify/",
                    Flurl.Url.Combine(rootPath, "/Payment/Final")
                    );
            }
            catch (Exception)
            {
                //TODO: Log and display error
            }

            return(Redirect(redirectUrl));
        }
Esempio n. 2
0
        public IHttpActionResult Create([FromBody] OrderModel order)
        {
            if (order == null)
            {
                return(BadRequest());
            }

            try
            {
                _orders.Create(order);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }