public HttpResponseMessage Post([FromBody] Models.country country) { try { if (string.IsNullOrEmpty(country.country_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Country Name is Empty" }, formatter)); } if ((country.country_code.Length > 3)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Country Code and Length is invalid" }, formatter)); } if (string.IsNullOrEmpty(country.country_code.ToUpper())) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Country Code is Empty" }, formatter)); } else { if (countryRepository.CheckDuplicateCountry(country.country_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Country Already Exists" }, formatter)); } else { Models.country insertCountry = new Models.country { country_name = country.country_name, country_code = country.country_code.ToUpper().Trim(), is_active = true, is_deleted = false, created_by = country.created_by, created_date = DateTime.Now, updated_by = country.updated_by, updated_date = DateTime.Now }; bool save_country = countryRepository.InsertCountry(insertCountry); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Country save successfully" }, formatter)); } } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }