public HttpResponseMessage post(DamageOrder Do) { try { var identity = User.Identity as ClaimsIdentity; int compid = 0, userid = 0; foreach (Claim claim in identity.Claims) { if (claim.Type == "compid") { compid = int.Parse(claim.Value); } if (claim.Type == "userid") { userid = int.Parse(claim.Value); } } Do.CompanyId = compid; logger.Info("User ID : {0} , Company Id : {1}", compid, userid); var data = context.AddDamageOrder(Do); if (data == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Error Occured")); } return(Request.CreateResponse(HttpStatusCode.OK, data)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message)); } }