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)); }
public IHttpActionResult Create([FromBody] OrderModel order) { if (order == null) { return(BadRequest()); } try { _orders.Create(order); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }