예제 #1
0
        public IHttpActionResult GetById(int id)
        {
            GetSaleCustomerResponse response = new GetSaleCustomerResponse();

            try
            {
                List <SaleCustomer> saleCustomers = saleCustomerBL.GetSaleCustomer(id);
                response.SaleCustomers = saleCustomers;
                response.Success       = true;
            }
            catch (SaleCustomerException ex)
            {
                response.ErrorCode    = ex.Error;
                response.ErrorMessage = "Error. " + ex.Error.ToString();
                response.Success      = false;
            }
            catch (Exception ex)
            {
                response.ErrorMessage = "Error. " + ex.Message;
                response.Success      = false;
            }
            return(Ok(response));
        }
예제 #2
0
 public void UpdateCurrentSaleCustomer()
 {
     if (saleCustomerView.SelectedId == -1)
     {
         saleCustomerView.CurrentSaleCustomer = new SaleCustomer();
     }
     else
     {
         HttpClient client = new HttpClient();
         client.BaseAddress = new Uri(baseUrl);
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token.access_token);
         HttpResponseMessage response = client.GetAsync(string.Format("{0}?id={1}", getByIdAction, saleCustomerView.SelectedId)).Result;
         if (response.IsSuccessStatusCode)
         {
             GetSaleCustomerResponse getSaleCustomerResponse = response.Content.ReadAsAsync <GetSaleCustomerResponse>().Result;
             if (getSaleCustomerResponse.Success)
             {
                 PropertyCopier.CopyProperties(getSaleCustomerResponse.SaleCustomers[0], saleCustomerView.CurrentSaleCustomer);
                 saleCustomerView.CurrentSaleCustomer.RaiseUpdateProperties();
             }
         }
     }
 }