public int Add(Product aType) { int returnValue = -1; returnValue = new ProductDataHelper().Insert(aType); return(returnValue); }
public BindingList <Product> Show(Product aType) { try { var myList = new ProductDataHelper().SelectAll(); var bindingList = new BindingList <Product>(myList); return(bindingList); } catch (ArgumentNullException) { throw new DataExistence("No Data Found! No Plots are yet added."); } }
public async Task <ServiceResponse <(List <Product>, bool)> > GetUserProducts(int?userId, int?supplierId, int productTypeMasterId) { var headers = RequestHeaderCreator.GetWebApiClientHeader(); GetProductsReqBody getProdsReq = new GetProductsReqBody { UsrId = userId, SupplierId = supplierId, ProductTypeMasterId = productTypeMasterId }; var response = await _restClient .ExecuteAsync <string, GetProductsReqBody>( HttpVerb.POST, action : "/product/getSupplierProducts", paramMode : HttpParamMode.BODY, requestBody : getProdsReq, headers : headers, apiRoutePrefix : $"{AppSettings.ApiEndpoint}" ); if (!response.IsOK() || string.IsNullOrEmpty(response.StringData)) { return(new ServiceResponse <(List <Product>, bool)>(ServiceStatus.Error, data: (null, false), errorCode: LinCTrasactionStatus.Failure.ToString(), errorMessage: "Problem in retrieving user data")); } var jSonResponse = response.StringData.Replace(@"\", string.Empty); if (jSonResponse.Contains("errorMessage")) { return(new ServiceResponse <(List <Product>, bool)>(ServiceStatus.Error, data: (null, false), errorCode: LinCTrasactionStatus.Failure.ToString(), errorMessage: "Please enter valid credential.")); } var prodsResponse = JsonConvert.DeserializeObject <ProductsResponse>(jSonResponse); //convert response.... List <Product> products = ProductDataHelper.ConvertResponseProducts(prodsResponse); return(new ServiceResponse <(List <Product>, bool)>(ServiceStatus.Success, data: (products, true))); }
public BindingSource GetList() { ProductDataHelper DH = new ProductDataHelper(); BindingSource BS = new BindingSource(); Hashtable HT = new Hashtable(); List <Product> myList = DH.SelectAll(); if (myList != null) { foreach (var item in myList) { if (item.State == EntityState.Enabled) { HT.Add(item.ID, item.PlotNo + "-" + item.Block); } } } HT.Add(-1, "Select Product"); BS.DataSource = HT; return(BS); }