public Task <bool> modifyGoal(ModifyGoalDTO data) => Task.Run(() => { Goal goal = context.Goal.First(a => a.Goalid == data.goalId); goal.Goalname = data.newGoalName; goal.Moneyrequired = data.newMoneyRequired; goal.Goalexpectedtime = data.newExpectedTime; context.SaveChanges(); return(true); });
public async Task <bool> ModifyGoal(ModifyGoalDTO data) { string json = JsonConvert.SerializeObject(data); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Put, "http://194.5.157.98:88/api/Goal"); message.Content = new StringContent(json, Encoding.UTF8, "application/json"); try { var response = await App.client.SendAsync(message); response.EnsureSuccessStatusCode(); return(true); } catch (Exception ex) { Logger.Log(string.Format("ModifyGoal: {0}", ex.ToString())); } return(false); }
public async Task <IActionResult> ModifyGoal([FromBody] ModifyGoalDTO data) { await Task.Run(() => _goalProcessor.modifyGoal(data)); return(Ok("Goal modified")); }