public int AddSupplierType(SupplierTypeDTO dto) { int id = 0; try { log.Debug(SupplierTypeDTO.FormatSupplierTypeDTO(dto)); R_SupplierType t = SupplierTypeDTO.ConvertDTOtoEntity(dto); // add id = Repository.AddSupplierType(t); dto.SupplierTypeId = id; log.Debug("result: 'success', id: " + id); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } return(id); }
public HttpResponseMessage Post([FromBody] Models.supplier_type objSupplierType, long?created_by) { try { if (string.IsNullOrEmpty(objSupplierType.supplier_type_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Supplier Type is Empty" }, formatter)); } else { if (_supplierTypeRepository.CheckDuplicateSupplierType(objSupplierType.supplier_type_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Supplier Type Already Exists" }, formatter)); } else { supplier_type insertSupplierType = new supplier_type { supplier_type_name = objSupplierType.supplier_type_name, created_by = objSupplierType.created_by, created_date = DateTime.Now, is_deleted = objSupplierType.is_deleted = false, is_active = objSupplierType.is_active = true }; bool saveSupplierType = _supplierTypeRepository.AddSupplierType(insertSupplierType, created_by); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Supplier Type save successfully" }, formatter)); } } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }