public async Task <ActionResult <ThanksCardTag> > PostThanksCardTag(ThanksCardTag thanksCardTag) { _context.ThanksCardTag.Add(thanksCardTag); await _context.SaveChangesAsync(); return(CreatedAtAction("GetThanksCardTag", new { id = thanksCardTag.Id }, thanksCardTag)); }
async void ExecuteSubmitCommand() { System.Diagnostics.Debug.WriteLine(this.Tags); //選択された Tag を取得し、ThanksCard.ThanksCardTags にセットする。 List <ThanksCardTag> ThanksCardTags = new List <ThanksCardTag>(); foreach (var tag in this.Tags.Where(t => t.Selected)) { ThanksCardTag thanksCardTag = new ThanksCardTag(); thanksCardTag.TagId = tag.Id; ThanksCardTags.Add(thanksCardTag); } this.ThanksCard.ThanksCardTags = ThanksCardTags; ThanksCard createdThanksCard = await ThanksCard.PostThanksCardAsync(this.ThanksCard); //TODO: Error handling this.regionManager.RequestNavigate("ContentRegion", nameof(Views.ThanksCardList)); const string message = "送信しました"; const string caption = "お知らせ"; System.Windows.Forms.MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information); }
public async Task <IActionResult> PutThanksCardTag(long id, ThanksCardTag thanksCardTag) { if (id != thanksCardTag.Id) { return(BadRequest()); } _context.Entry(thanksCardTag).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThanksCardTagExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
async void ExecuteSubmitCommand() { System.Diagnostics.Debug.WriteLine(this.Tags); //選択された Tag を取得し、ThanksCard.ThanksCardTags にセットする。 List <ThanksCardTag> ThanksCardTags = new List <ThanksCardTag>(); foreach (var tag in this.Tags.Where(t => t.Selected)) { ThanksCardTag thanksCardTag = new ThanksCardTag(); thanksCardTag.TagId = tag.Id; ThanksCardTags.Add(thanksCardTag); } this.ThanksCard.ThanksCardTags = ThanksCardTags; ThanksCard createdThanksCard = await ThanksCard.PostThanksCardAsync(this.ThanksCard); //TODO: Error handling this.regionManager.RequestNavigate("ContentRegion", nameof(Views.ThanksCardList)); }
public LINQTest(AppDbContext context) { this._context = context; // Usersテーブルが空なら初期データを作成する。 if (_context.Users.Count() == 0) { var dept1 = new Department { Code = 1, Name = "dept1", Parent = null }; var dept2 = new Department { Code = 2, Name = "dept2", Parent = dept1 }; _context.Departments.Add(dept1); _context.Departments.Add(dept2); var admin = new User { Name = "admin", Password = "******", IsAdmin = true, Department = dept1 }; var user1 = new User { Name = "user1", Password = "******", IsAdmin = false, Department = dept1 }; var user2 = new User { Name = "user2", Password = "******", IsAdmin = false, Department = dept2 }; _context.Users.Add(admin); _context.Users.Add(user1); _context.Users.Add(user2); var tag1 = new Tag { Name = "tag1" }; var tag2 = new Tag { Name = "tag2" }; var tag3 = new Tag { Name = "tag3" }; _context.Tags.Add(tag1); _context.Tags.Add(tag2); _context.Tags.Add(tag3); var thanksCard1 = new ThanksCard { Title = "title1", Body = "body1", From = admin, To = user1, CreatedDateTime = DateTime.Now }; var thanksCard2 = new ThanksCard { Title = "title2", Body = "body2", From = admin, To = user1, CreatedDateTime = DateTime.Now }; var thanksCard3 = new ThanksCard { Title = "title3", Body = "body3", From = admin, To = user1, CreatedDateTime = DateTime.Now }; var thanksCard4 = new ThanksCard { Title = "title4", Body = "body4", From = admin, To = user2, CreatedDateTime = DateTime.Now }; var thanksCard5 = new ThanksCard { Title = "title5", Body = "body5", From = admin, To = user2, CreatedDateTime = DateTime.Now }; var thanksCard6 = new ThanksCard { Title = "title6", Body = "body6", From = user1, To = admin, CreatedDateTime = DateTime.Now }; var thanksCard7 = new ThanksCard { Title = "title7", Body = "body7", From = user2, To = admin, CreatedDateTime = DateTime.Now }; _context.ThanksCards.Add(thanksCard1); _context.ThanksCards.Add(thanksCard2); _context.ThanksCards.Add(thanksCard3); _context.ThanksCards.Add(thanksCard4); _context.ThanksCards.Add(thanksCard5); _context.ThanksCards.Add(thanksCard6); _context.ThanksCards.Add(thanksCard7); var thanksCardTag1 = new ThanksCardTag { ThanksCard = thanksCard1, Tag = tag1 }; var thanksCardTag2 = new ThanksCardTag { ThanksCard = thanksCard1, Tag = tag2 }; var thanksCardTag3 = new ThanksCardTag { ThanksCard = thanksCard2, Tag = tag2 }; var thanksCardTag4 = new ThanksCardTag { ThanksCard = thanksCard2, Tag = tag3 }; _context.ThanksCardTags.Add(thanksCardTag1); _context.ThanksCardTags.Add(thanksCardTag2); _context.ThanksCardTags.Add(thanksCardTag3); _context.ThanksCardTags.Add(thanksCardTag4); _context.SaveChanges(); } // Data テーブルが空なら初期データを作成する。 if (_context.Data.Count() == 0) { for (int i = 0; i < 10; i++) { Data data = new Data { Value = i * 10 + (i * i), DateTime = DateTime.Now }; _context.Data.Add(data); } _context.SaveChanges(); } }