public HttpResponseMessage Post([FromBody] Models.brand brand) { try { if (string.IsNullOrEmpty(brand.brand_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Brand is Empty" }, formatter)); } else { if (brandRepository.CheckDuplicateBrands(brand.brand_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Brand Already Exists" }, formatter)); } else { brand insert_brand = new brand { brand_name = brand.brand_name }; brandRepository.Addbrand(insert_brand); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Brand save successfully" }, formatter)); } } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }