Example #1
0
        public HttpResponseMessage ForgivPassword(string userName, string email)
        {
            if (Request.Method == HttpMethod.Options)
            {
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }

            WebServiceResult retVal = new WebServiceResult()
            {
                Message = "OK", Result = ""
            };

            try
            {
                UserBusinessLayer bl = new UserBusinessLayer();
                retVal = bl.ForgivPassword(userName, email);

                var status = HttpStatusCode.OK;
                if (retVal.Message != "OK")
                {
                    status = HttpStatusCode.InternalServerError;
                }
                if (retVal.Message != "OK")
                {
                    return new HttpResponseMessage(status)
                           {
                               Content = new StringContent(JsonConvert.SerializeObject(retVal), Encoding.UTF8, "application/json")
                           }
                }
                ;
                else
                {
                    return new HttpResponseMessage(status)
                           {
                               Content = new StringContent(JsonConvert.SerializeObject(retVal.Result), Encoding.UTF8, "application/json")
                           }
                };
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(JsonConvert.SerializeObject(ex), Encoding.UTF8, "application/json")
                });
            }
        }