// Build Error private ICommonError BadReqErr(string msg) { ICommonError err = errorBuilder.ClientError("Bad Request: " + msg); err.StatusCode = 400; //err.Message = msg; errorBuilder.EerectTo(err, this.Response); return(err); }
public object Post([FromBody] NVASD_Incoming value) { ICommonError err = _errorBuilder.Success(""); object ret; if (value != null) { _context.NvaSdIncoming.Access.Inserter.Add(value); var rt = _context.Save(); if (rt != null && rt != "") { err = _errorBuilder.ClientError(rt); err.Name = "Unprocessable Entity"; err.StatusCode = 422; _errorBuilder.EerectTo(err, this.Response); ret = err; } else { ret = _context.NvaSdIncoming.Access.Reader.Find(value.ID); } } else { //this.Response.Body.Position = 0; var s = ""; if (this.Request.Body.Length > 0) { this.Request.Body.Position = 0; s = new StreamReader(this.Request.Body, Encoding.UTF8).ReadToEnd(); } err = _errorBuilder.ClientError("Bad Request"); err.StatusCode = 400; err.Message = string.IsNullOrEmpty(s) ? "Incoming data is empty" : "Incoming data is bad: [" + s + "]"; _errorBuilder.EerectTo(err, this.Response); ret = err; } return(ret); }