Ejemplo n.º 1
0
        public HttpResponseMessage GetCitiesByState(StatesModel states)
        {
            ResponseStatus response = new ResponseStatus();

            try
            {
                if (states.StateId > 0)
                {
                    var data = _repository.GetCitiesByState(states.StateId);
                    if (data.Count() > 0)
                    {
                        response.isSuccess          = true;
                        response.serverResponseTime = System.DateTime.Now;
                        return(Request.CreateResponse(HttpStatusCode.OK, new { data, response }));
                    }
                    else
                    {
                        response.isSuccess          = false;
                        response.serverResponseTime = System.DateTime.Now;
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, new { response }));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Worng !"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Worng !", ex));
            }
        }