public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Mail,Password,GoogleToken,TodoTitle,PersonId")] Todo todo) { if (id != todo.ID) { return(NotFound()); } if (ModelState.IsValid) { try { var key = _appOptions.Value.AccountKey; var name = _appOptions.Value.AccountName; imgUpload img = new imgUpload(); string imgPath = img.ImgUpload(Request.HttpContext, name, key); _context.Update(todo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodoExists(todo.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(todo)); }
public async Task <IActionResult> MainForm() { if (ModelState.IsValid) { int userID = int.Parse(TempData["userID"].ToString()); var todo = await _context.Todo.SingleOrDefaultAsync(m => m.ID == userID); try { //顔画像のパス取得 var key = _appOptions.Value.AccountKey; var name = _appOptions.Value.AccountName; imgUpload img = new imgUpload(); string imgPath = img.ImgUpload(Request.HttpContext, name, key); //名前でPERSON作成+画像をPERSONへ追加 var subscriptionKey = _faceApiOptions.Value.Subscriptionkey; var groupName = _faceApiOptions.Value.GroupName; AddPerson face = new AddPerson(); string personId = face.addPerson(subscriptionKey, groupName, todo.Name, imgPath); todo.PersonId = personId; _context.Update(todo); await _context.SaveChangesAsync(); if (todo.PersonId != null) { ViewBag.imgRegister = "画像のアップが完了しています。OK"; } else { ViewBag.imgNoRegister = "画像のアップが未完了です!"; } ViewBag.name = "ログイン中:" + todo.Name; TempData["userID"] = userID; return(View("mainForm")); } catch (DbUpdateConcurrencyException) { if (!TodoExists(todo.ID)) { return(NotFound()); } else { throw; } } } return(View()); }