示例#1
0
        public void DeleteIndustry(IndustryEntity newEntity)
        {
            IndustryEntity oldEntity = IndustryList.FirstOrDefault <IndustryEntity>(p => p.IndustryId == newEntity.IndustryId);

            if (oldEntity != null)
            {
                IndustryList.Remove(oldEntity);
            }

            IndustryList = new List <IndustryEntity>(_industryList);
        }
示例#2
0
        public void Add()
        {
            var newEntity = new IndustryEntity()
            {
                Deleted     = false,
                Description = "",
                IndustryId  = -1
            };

            IndustryList.Add(newEntity);
            IndustryList = new List <IndustryEntity>(_industryList);
        }
示例#3
0
        public void Reload()
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                    var _obusinessList = Factory.Resolve <IBaseDataDS>().SearchBusiness(new BusinessSearchEntity()
                    {
                        SearchText = ""
                    });

                    var _oindustryList = Factory.Resolve <IBaseDataDS>().SearchIndustry(new IndustrySearchEntity()
                    {
                        SearchText = ""
                    });
                    HideLoading();

                    //display to UI
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        BusinessEntity itbs = new BusinessEntity()
                        {
                            BusinessId = 0, Description = ""
                        };
                        BusinessList = _obusinessList;
                        BusinessList.Insert(0, itbs);
                        SelectedBusiness    = BusinessList.FirstOrDefault();
                        IndustryEntity itin = new IndustryEntity()
                        {
                            IndustryId = 0, Description = ""
                        };
                        IndustryList = _oindustryList;
                        IndustryList.Insert(0, itin);
                        SelectedIndustry = IndustryList.FirstOrDefault();
                    }));
                }
                catch (Exception ex)
                {
                    HideLoading();
                    ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                }
            });
            //ShowDialog<uvCompanyDetailViewModel>(new uvCompanyDetailViewModel() {
            //    OriginalCompany = SelectCompany
            //});
        }
示例#4
0
        public void AddOrUpdateIndustry(IndustryEntity newEntity)
        {
            IndustryEntity oldEntity = IndustryList.FirstOrDefault <IndustryEntity>(p => p.Description == newEntity.Description);

            if (oldEntity == null)
            {
                IndustryList.Insert(0, newEntity);
            }
            else
            {
                int index = IndustryList.IndexOf(oldEntity);
                IndustryList.Remove(oldEntity);
                IndustryList.Insert(index, newEntity);
            }

            IndustryList = new List <IndustryEntity>(_industryList);
        }
        /// <param name='brand'>
        /// Required.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public async Task <HttpOperationResponse <IndustryList> > GetAllIndustryByBrandWithOperationResponseAsync(string brand, CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            // Validate
            if (brand == null)
            {
                throw new ArgumentNullException("brand");
            }

            // Tracing
            bool   shouldTrace  = ServiceClientTracing.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("brand", brand);
                ServiceClientTracing.Enter(invocationId, this, "GetAllIndustryByBrandAsync", tracingParameters);
            }

            // Construct URL
            string url = "";

            url = url + "/brands/";
            url = url + Uri.EscapeDataString(brand);
            url = url + "/grouporders/industries";
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = new HttpRequestMessage();

            httpRequest.Method     = HttpMethod.Get;
            httpRequest.RequestUri = new Uri(url);

            // Set Credentials
            if (this.Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);
            }

            // Send Request
            if (shouldTrace)
            {
                ServiceClientTracing.SendRequest(invocationId, httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            HttpResponseMessage httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

            if (shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(invocationId, httpResponse);
            }
            HttpStatusCode statusCode = httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (statusCode != HttpStatusCode.OK)
            {
                HttpOperationException <object> ex = new HttpOperationException <object>();
                ex.Request  = httpRequest;
                ex.Response = httpResponse;
                ex.Body     = null;
                if (shouldTrace)
                {
                    ServiceClientTracing.Error(invocationId, ex);
                }
                throw ex;
            }

            // Create Result
            HttpOperationResponse <IndustryList> result = new HttpOperationResponse <IndustryList>();

            result.Request  = httpRequest;
            result.Response = httpResponse;

            // Deserialize Response
            if (statusCode == HttpStatusCode.OK)
            {
                IndustryList resultModel = new IndustryList();
                JToken       responseDoc = null;
                if (string.IsNullOrEmpty(responseContent) == false)
                {
                    responseDoc = JToken.Parse(responseContent);
                }
                if (responseDoc != null)
                {
                    resultModel.DeserializeJson(responseDoc);
                }
                result.Body = resultModel;
            }

            if (shouldTrace)
            {
                ServiceClientTracing.Exit(invocationId, result);
            }
            return(result);
        }