public IHttpActionResult PostCustomBill(CustomBillModel customBillModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var customBill = new CustomBill { BillName = customBillModel.BillName, EstimatedAmount = customBillModel.EstimatedAmount, UserId = customBillModel.UserId, WebsiteUrl = customBillModel.WebsiteUrl }; db.CustomBills.Add(customBill); try { db.SaveChanges(); } catch (DbUpdateException) { if (CustomBillExists(customBill.CustomBillId)) { return(Conflict()); } else { throw; } } customBillModel.CustomBillId = customBill.CustomBillId; return(Ok(customBillModel)); }
public async Task <EResponseBase <CustomBillModel> > UpdateAsync(CustomBillModel Customer) { var request = JsonConvert.SerializeObject(Customer); var content = new StringContent(request, Encoding.UTF8, "application/json"); var client = new HttpClient(); string baseUrl = ApiUrlHelper.BaseUrl(); client.BaseAddress = new Uri(baseUrl); var url = string.Concat(baseUrl, "/api/Bill/UpdateBill"); var response = client.PutAsync(url, content).Result; if (response.StatusCode == HttpStatusCode.OK) { var result = await response.Content.ReadAsStringAsync(); var exito = JsonConvert.DeserializeObject <bool>(result); return(new EResponseBase <CustomBillModel> { Status = exito, Code = 0, Message = "Exito" }); } else { return(new EResponseBase <CustomBillModel> { Status = false, Code = (int)response.StatusCode, Message = "Error" }); } }