コード例 #1
0
        /// <summary>
        /// Return a company address
        /// </summary>
        /// <param name="email"></param>
        /// <param name="rooturl"></param>
        /// <param name="encodedId"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <CompanyAddressModel> GetCompanyAddress(string email, string rooturl, string encodedId, int id)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(rooturl) || string.IsNullOrEmpty(encodedId) || id <= 0)
            {
                return(null);
            }

            string queryname           = WebTasksTypeConstants.GetCompanyAddress;
            string queryterms          = WebApiServices.GetJsonQuerySearchTermsCompanyAddressId(id.ToString());
            string url                 = $"{rooturl}api/webtasks?queryname={queryname}&queryterms={queryterms}";
            CompanyAddressModel result = null;

            LoggingService service   = new LoggingService();
            var            stopwatch = new Stopwatch();

            try
            {
                var response = await new WebApiServices().GetData(url, encodedId);
                if (!string.IsNullOrEmpty(response))
                {
                    result = new SerializerServices()
                             .DeserializeObject <CompanyAddressModel>(response.NormalizeJsonString());
                }
            }
            catch (Exception ex)
            {
                service.TrackException(ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                var properties = new Dictionary <string, string>
                {
                    { "UserEmail", email },
                    { "WebServicesEndpoint", rooturl },
                    { "EncodedId", encodedId },
                    { "CompanyAddressId", id.ToString() }
                };
                service.TrackEvent(LoggingServiceConstants.GetCompanyAddress, stopwatch.Elapsed, properties);
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Delete the specified company
        /// </summary>
        /// <param name="id"></param>
        /// <param name="encodedId"></param>
        /// <param name="rooturl"></param>
        /// <returns></returns>
        public async Task <bool> DeleteCompanyAddress(int id, string encodedId, string rooturl)
        {
            if (id <= 0 || string.IsNullOrEmpty(encodedId) || string.IsNullOrEmpty(rooturl))
            {
                return(false);
            }

            bool   result;
            string queryterms = WebApiServices.GetJsonQuerySearchTermsCompanyAddressId(id.ToString());

            string url = $"{rooturl}api/webtasks?formname={RoutingTasksTypeConstants.DeleteCompanyAddress}&queryterms={queryterms}";

            LoggingService service   = new LoggingService();
            var            stopwatch = new Stopwatch();

            try
            {
                var response = await new WebApiServices().DeleteData(url, encodedId);
                result = response.IsSuccessStatusCode;
            }
            catch (Exception ex)
            {
                service.TrackException(ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                var properties = new Dictionary <string, string>
                {
                    { "CompanyAddressId", id.ToString() },
                    { "EncodedId", encodedId },
                    { "WebServicesEndpoint", rooturl }
                };
                service.TrackEvent(LoggingServiceConstants.DeleteCompanyAddress, stopwatch.Elapsed, properties);
            }
            return(result);
        }