public Task <bool> ModifyIncome(ModifyIncomeDTO data) => Task.Run(() => { var income = context.Income.First(a => a.Incomeid == data.incomeId); income.Incomename = data.incomeName; income.Moneyrecieved = (float)data.moneyReceived; context.SaveChanges(); return(true); });
public async Task <bool> ModifyIncome(ModifyIncomeDTO data) { string json = JsonConvert.SerializeObject(data); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Put, "http://194.5.157.98:88/api/Income"); message.Content = new StringContent(json, Encoding.UTF8, "application/json"); try { var response = await App.client.SendAsync(message); response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) { return(true); } } catch (Exception ex) { Logger.Log(string.Format("ModifyIncome: {0}", ex.ToString())); } return(false); }
public async Task <IActionResult> ModifyIncome([FromBody] ModifyIncomeDTO data) { await Task.Run(() => inp.ModifyIncome(data)); return(Ok("Income modified")); }