public HttpResponseMessage Put([FromBody] Models.sales_type objSalesType) { try { if (string.IsNullOrEmpty(objSalesType.sales_type1)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Sales Type Name is Empty" }, formatter)); } else { Models.sales_type updateSales = new Models.sales_type { sales_type_id = objSalesType.sales_type_id, sales_type1 = objSalesType.sales_type1, is_active = objSalesType.is_active }; bool irepoUpdate = salesTypeRepository.UpdateSalesType(updateSales); if (irepoUpdate == true) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Sales Type Update successfully" }, formatter)); } else { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Update Failed" }, formatter)); } } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }
public HttpResponseMessage Post([FromBody] Models.sales_type objSalesType) { try { if (string.IsNullOrEmpty(objSalesType.sales_type1)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Sales Type is Empty" }, formatter)); } else { if (salesTypeRepository.CheckDuplicateSalesType(objSalesType.sales_type1)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Sales Type Already Exists" }, formatter)); } else { Models.sales_type insertSales = new Models.sales_type { sales_type1 = objSalesType.sales_type1, is_active = objSalesType.is_active }; salesTypeRepository.InsertSalesType(insertSales); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Sales Type save successfully" }, formatter)); } } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }
public HttpResponseMessage Delete([FromBody] Models.sales_type objSalesType) { try { bool delete = salesTypeRepository.DeleteSalesType(objSalesType.sales_type_id); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Sales Type Delete Successfully." }, formatter)); } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }