public async Task CreatePhoneBook(Domain.Entities.PhoneBook phoneBook) { HttpResponseMessage httpResponse = new HttpResponseMessage(); try { using (HttpClient client = Client()) { string json = JsonConvert.SerializeObject(phoneBook); HttpContent data = Content(json); //new StringContent(json, Encoding.UTF8, "application/json"); httpResponse = await client.PostAsync("/api/PhoneBook/CreatePhoneBook", data); // if (httpResponse == null) // return null; using (HttpContent content = httpResponse.Content) { string result = await content.ReadAsStringAsync(); //if(((int)httpResponse.statusCode)!=200) var response = JsonConvert.DeserializeObject(result); //return response; } } } catch (HttpRequestException ex) { } catch (Exception ex) { } }
public PhoneBookVM PhoneBookVMObj(Domain.Entities.PhoneBook phoneBook) { if (phoneBook != null) { return new PhoneBookVM { Id = phoneBook.Id, Name = phoneBook.Name, //Entries = phoneBook.Entries } } ; return(new PhoneBookVM()); }
private void InsertPhoneBook(Domain.Entities.PhoneBook phoneBook) { unitOfWork.PhoneBookRepository.Insert(phoneBook); unitOfWork.Save(); }
public async Task CreatePhoneBook(Domain.Entities.PhoneBook phoneBook) { await Task.Run(() => InsertPhoneBook(phoneBook)); }