Esempio n. 1
0
 public static VisitStateViewModel Create(VisitStateDto visitState, string returnUrl)
 {
     return(new VisitStateViewModel
     {
         VisitState = visitState,
         ReturnUrl = returnUrl
     });
 }
Esempio n. 2
0
 public static VisitStateViewModel Delete(VisitStateDto visitState, string returnUrl)
 {
     return(new VisitStateViewModel
     {
         VisitState = visitState,
         Action = "Delete",
         ReadOnly = true,
         Theme = "danger",
         ReturnUrl = returnUrl
     });
 }
Esempio n. 3
0
 public static VisitStateViewModel Edit(VisitStateDto visitState, string returnUrl)
 {
     return(new VisitStateViewModel
     {
         VisitState = visitState,
         Theme = "warning",
         Action = "Edit",
         ShowCreateNewAction = true,
         ReturnUrl = returnUrl
     });
 }
Esempio n. 4
0
 public static VisitStateViewModel Details(VisitStateDto visitState, string returnUrl)
 {
     return(new VisitStateViewModel
     {
         VisitState = visitState,
         Action = "Details",
         ReadOnly = true,
         Theme = "info",
         ShowAction = false,
         ReturnUrl = returnUrl
     });
 }
Esempio n. 5
0
 public async Task DeleteVisitState(VisitStateDto visitState)
 {
     using (var httpClient = new HttpClient())
     {
         using (var response = await httpClient.DeleteAsync(uri.AbsoluteUri + visitState.Id))
         {
             if (!response.IsSuccessStatusCode)
             {
                 //string apiResponse = await response.Content.ReadAsStringAsync();
                 throw new Exception();
             }
         }
     }
 }
Esempio n. 6
0
        public async Task UpdateVisitState(VisitStateDto visitState)
        {
            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(visitState), Encoding.UTF8, "application/json");

                using (var response = await httpClient.PutAsync(uri.AbsoluteUri + visitState.Id, content))
                {
                    if (!response.IsSuccessStatusCode)
                    {
                        throw new Exception();
                    }
                }
            }
        }
Esempio n. 7
0
        public async Task <VisitStateDto> GetVisitState(int id)
        {
            VisitStateDto visitState = new VisitStateDto();

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

                        visitState = JsonConvert.DeserializeObject <VisitStateResponseDto>(apiResponse).VisitState;
                    }
                }
            }
            return(visitState);
        }
Esempio n. 8
0
        public async Task <VisitStateDto> AddVisitState(VisitStateDto visitState)
        {
            VisitStateDto receivedVisitState = new VisitStateDto();

            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(visitState), 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();

                    receivedVisitState = JsonConvert.DeserializeObject <VisitStateResponseDto>(apiResponse).VisitState;
                }
            }
            return(receivedVisitState);
        }