Ejemplo n.º 1
0
        public string PurchaseEntity(string body)
        {
            string    token     = TokenHelper.GetTokenJson(HttpContext.Request.Headers["Authorization"]);
            TokenInfo tokenInfo = JSONHelper.JSONToObject <TokenInfo>(token);
            User      p         = new User();

            p.Name = tokenInfo.UserName;
            User     user     = userService.getUserByName(p);
            Purchase purchase = JSONHelper.JSONToObject <Purchase>(body);

            purchase.OperatorId = user.Id;
            Purchase res = fixtureService.PurhaseRequest(purchase);

            if (res != null)
            {
                return(JSONHelper.ObjectToJSON(ResponseUtil.Ok(res)));
            }
            else
            {
                return(JSONHelper.ObjectToJSON(ResponseUtil.Fail()));
            }
        }