Пример #1
0
        public ActionResult <string> GetUser(int id)
        {
            string result = "";

            if (Program.errorStatus == PasswdErrors.PasswdError.NoError)
            {
                result = APIMethods.GetUser(Program.dataSet.Tables["UserTable"], id);
            }

            if (Program.errorStatus != PasswdErrors.PasswdError.NoError)
            {
                JObject jObject = PasswdErrors.errorHandler(Program.errorStatus);
                Response.StatusCode = (int)jObject["StatusCode"];

                result = jObject.ToString();
            }
            else if (result.Length == 0 || result == null)
            {
                Response.StatusCode = 404;
                JObject jObject = new JObject();

                jObject.Add("error", $"User with id {id} not found.");
                jObject.Add("error code", Response.StatusCode);

                result = jObject.ToString();
            }
            return(result);
        }