public void OnNavigatedTo(NavigationContext navigationContext) { Debug.WriteLine("OnNavigatedTo"); TodoDetailData todoDetailData = navigationContext.Parameters["SelectedDetailItem"] as TodoDetailData; this.navigationService = navigationContext.NavigationService; //公式参照するとこっちが書いてあるのでこっちでは?http://vdlz.xyz/Csharp/ToolKit/MVVM/Prism/Doc/DG50/DG50_005.html //画面遷移時のデータ取得(ここで良いのかな?) this.SelectedDetailItem = todoDetailData; }
public ToDoListControlViewModel() { //初期データ取得 //GridItem = toDoList.GetUserList().Result; var list = new List <TodoDetailData>() { new TodoDetailData() { UserId = 0 , DataId = 0 } }; GridItem = list; //コマンド生成 this.GetMainListCommand = new DelegateCommand(() => { GetUserDataList(); }); this.AddCommand = new DelegateCommand(() => { var baseData = GridItem.FirstOrDefault(); int userId = baseData?.UserId ?? 0; int dataId = baseData?.DataId + 1 ?? 0; var data = new TodoDetailData() { UserId = userId , DataId = dataId }; var result = toDoList.Post(data, GridItem).Result; ToDetail(result); }); this.UpdCommand = new DelegateCommand(() => { this.NotificationRequest.Raise(new Notification { Title = "Alert", Content = "未実装です" }); }); this.DelCommand = new DelegateCommand(() => { this.NotificationRequest.Raise(new Notification { Title = "Alert", Content = "未実装です" }); }); this.DetailCommand = new DelegateCommand(() => { ToDetail(SelectedItem); }); }
public TodoDetailData TodoDetailDataUpdate([FromBody] TodoDetailData requestData) { { var data = _context.TodoDetailDataTmpPgs.Where(x => x.UserId == requestData.UserId && x.DataId == requestData.DataId); foreach (TodoDetailDataTmpPg item in data) { Clone.Convert(requestData, item); _context.Entry(item).State = EntityState.Modified; } _context.SaveChanges(); var result = Clone.Convert <TodoDetailData>(data); return(result); } }
/// <summary> /// 指定の物を追加or更新する /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public async Task <string> PutById(TodoDetailData data) { var js = new Newtonsoft.Json.JsonSerializer(); var sw = new System.IO.StringWriter(); js.Serialize(sw, data); var hc = new HttpClient(); hc.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var json = sw.ToString(); var cont = new StringContent(json, Encoding.UTF8, "application/json"); var res = await hc.PutAsync(common.GetURL() + "TodoDetailDatas/", cont).ConfigureAwait(false);; var str = await res.Content.ReadAsStringAsync(); return(str); }
public async Task <IActionResult> TodoDetailDataAdd([FromBody] TodoDetailData requestData) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } { var addData = new TodoDetailDataTmpPg(); Clone.Convert(requestData, addData); addData.Id = _context.TodoDetailDataTmpPgs.Max(x => x.Id) + 1; //最大値に1増やす _context.TodoDetailDataTmpPgs.Add(addData); _context.SaveChangesAsync(); return(Ok(requestData)); } }
private void ToDetail(TodoDetailData detailInfo) { this.KeepAlive = false; //TODO:情報残るようなら以下のコメントを消す // find view by region var view = RegionManager.Regions["MainRegion"] .ActiveViews .First(x => MvvmHelpers.GetImplementerFromViewOrViewModel <ToDoListControlViewModel>(x) == this); // deactive view this.RegionManager.Regions["MainRegion"].Deactivate(view); NavigationParameters param = new NavigationParameters(); param.Add("SelectedDetailItem", detailInfo); this.RegionManager.RequestNavigate("MainRegion", nameof(ToDoDetailControlView), param); }
/// <summary> /// 指定の物を追加する /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public async Task <TodoDetailData> Post(TodoDetailData data, List <TodoDetailData> gridData) { //最新IDにする data.DataId = maxId(gridData); var js = new Newtonsoft.Json.JsonSerializer(); var sw = new System.IO.StringWriter(); js.Serialize(sw, data); var hc = new HttpClient(); hc.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var json = sw.ToString(); var cont = new StringContent(json, Encoding.UTF8, "application/json"); var res = await hc.PostAsync(common.GetURL() + "TodoDetailDatas", cont).ConfigureAwait(false);; var str = await res.Content.ReadAsStringAsync(); //testMess.Text = str; var jr = new Newtonsoft.Json.JsonTextReader(new System.IO.StringReader(str)); var item = js.Deserialize <TodoDetailData>(jr); return(item); }