Exemple #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));
            }
        }
        public JsonResult GetStatesbyCountry(StatesModel sm)
        {
            var res = "";

            try
            {
                string jsr = mps.GetStatesbyCountry(sm);
                return(Json((new JavaScriptSerializer()).DeserializeObject(jsr), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                res = ex.Message.ToString();
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
        }
        public string GetStatesbyCountry(StatesModel sm)
        {
            var res = "";

            try
            {
                string inputJson = (new JavaScriptSerializer()).Serialize(sm);
                string jsr       = GetjsonInfo("/ManPowers/GetStateList", inputJson);
                return(jsr);
            }
            catch (Exception ex)
            {
                ErrorWriter.WriteLog(ex.GetType().ToString(), ex.GetType().Name.ToString(), ex.InnerException.ToString(), "GetStatesbyCountry", "MainRepository");
                res = ex.Message.ToString();
                return(res);
            }
        }