コード例 #1
0
 public static RegisterControlViewModel Create(RegisterControlDto registerControl, string returnUrl)
 {
     return(new RegisterControlViewModel
     {
         RegisterControl = registerControl,
         ReturnUrl = returnUrl
     });
 }
コード例 #2
0
 public static RegisterControlViewModel Delete(RegisterControlDto registerControl, string returnUrl)
 {
     return(new RegisterControlViewModel
     {
         RegisterControl = registerControl,
         Action = "Delete",
         ReadOnly = true,
         Theme = "danger",
         ReturnUrl = returnUrl
     });
 }
コード例 #3
0
 public static RegisterControlViewModel Edit(RegisterControlDto registerControl, string returnUrl)
 {
     return(new RegisterControlViewModel
     {
         RegisterControl = registerControl,
         Theme = "warning",
         Action = "Edit",
         ShowCreateNewAction = true,
         ReturnUrl = returnUrl
     });
 }
コード例 #4
0
 public static RegisterControlViewModel Details(RegisterControlDto registerControl, string returnUrl)
 {
     return(new RegisterControlViewModel
     {
         RegisterControl = registerControl,
         Action = "Details",
         ReadOnly = true,
         Theme = "info",
         ShowAction = false,
         ReturnUrl = returnUrl
     });
 }
コード例 #5
0
 public async Task DeleteRegisterControl(RegisterControlDto registerControl)
 {
     using (var httpClient = new HttpClient())
     {
         using (var response = await httpClient.DeleteAsync(uri.AbsoluteUri + registerControl.Id))
         {
             if (!response.IsSuccessStatusCode)
             {
                 //string apiResponse = await response.Content.ReadAsStringAsync();
                 throw new Exception();
             }
         }
     }
 }
コード例 #6
0
        public async Task UpdateRegisterControl(RegisterControlDto registerControl)
        {
            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(registerControl), Encoding.UTF8, "application/json");

                using (var response = await httpClient.PutAsync(uri.AbsoluteUri + registerControl.Id, content))
                {
                    if (!response.IsSuccessStatusCode)
                    {
                        throw new Exception();
                    }
                }
            }
        }
コード例 #7
0
        public async Task <RegisterControlDto> GetRegisterControl(int id)
        {
            RegisterControlDto registerControl = new RegisterControlDto();

            using (var httpClient = new HttpClient())
            {
                using (var response = await httpClient.GetAsync(uri.AbsoluteUri + id))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        registerControl = JsonConvert.DeserializeObject <RegisterControlResponseDto>(apiResponse).RegisterControl;
                    }
                }
            }

            return(registerControl);
        }
コード例 #8
0
        public async Task <RegisterControlDto> AddRegisterControl(RegisterControlDto registerControl)
        {
            RegisterControlDto receivedRegisterControl = new RegisterControlDto();

            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(registerControl), Encoding.UTF8, "application/json");

                using (var response = await httpClient.PostAsync(uri.AbsoluteUri, content))
                {
                    if (!response.IsSuccessStatusCode)
                    {
                        throw new Exception();
                    }
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    receivedRegisterControl = JsonConvert.DeserializeObject <RegisterControlResponseDto>(apiResponse).RegisterControl;
                }
            }
            return(receivedRegisterControl);
        }