private AdmOut CadastrarLanche(Lanche lanche) { var admInserirOut = new AdmOut(); try { var config = new MapperConfiguration(cfg => { cfg.CreateMap <Lanche, AdmLancheIn>(); }); IMapper iMapper = config.CreateMapper(); var admLancheIn = iMapper.Map <Lanche, AdmLancheIn>(lanche); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Services.UrlBase); var response = client.PostAsJsonAsync(Services.UrlCadastrarLanche, admLancheIn).Result; admInserirOut.Sucesso = response.IsSuccessStatusCode; admInserirOut.Mensagem = response.Content.ReadAsStringAsync().Result; } return(admInserirOut); } catch (Exception) { throw; } }
private AdmOut EditarLanche(string id, Lanche lanche) { var admInserirOut = new AdmOut(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(Services.UrlBase); var response = client.PutAsJsonAsync(string.Format(Services.UrlEditarLanche, id), lanche).Result; admInserirOut.Sucesso = response.IsSuccessStatusCode; admInserirOut.Mensagem = response.Content.ReadAsStringAsync().Result; } return(admInserirOut); } catch (Exception) { throw; } }