protected void Page_Load(object sender, EventArgs e) { var categories = new List <Category>(); var tags = new List <Tag>(); var cat1 = new Category(); cat1.Id = "1"; cat1.Title = "Some Title"; var cat2 = new Category(); cat2.Id = "2"; cat2.Title = "Other Title"; categories.Add(cat1); categories.Add(cat2); var tag1 = new Tag(); tag1.Id = "1"; tag1.Title = "Some Tag"; var tag2 = new Tag(); tag2.Id = "2"; tag2.Title = "Other Tag"; tags.Add(tag1); tags.Add(tag2); var wikiEntry = new WikiEntry(txtTitle.Text, txtContent.Text, "John Doe", DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, "John Die", categories, tags); }
public async Task <IActionResult> PutWikiEntry([FromRoute] int id, [FromBody] WikiEntry wikiEntry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != wikiEntry.ID) { return(BadRequest()); } _context.Entry(wikiEntry).State = EntityState.Modified; try { await _context.SaveChangesAsync().ConfigureAwait(false); } catch (DbUpdateConcurrencyException) { if (!WikiEntryExists(id)) { return(NotFound()); } throw; } return(NoContent()); }
protected void btnCreate_Click(object sender, EventArgs e) { var wikiEntry = new WikiEntry(txtTitle.Text, txtContent.Text, "John Doe", DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, "John Die", categoriesList, tagsList); WikiDAL wikiDal = new WikiDAL(@"C:\Users\KDRENSKI\source\repos\Wiki\Wiki\App_Data\Wiki.xml"); wikiDal.Add(wikiEntry); wikiDal.Save(); }
public async Task <IActionResult> PostWikiEntry([FromBody] WikiEntry wikiEntry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.WikiEntries.Add(wikiEntry); await _context.SaveChangesAsync().ConfigureAwait(false); return(CreatedAtAction("GetWikiEntry", new { id = wikiEntry.ID }, wikiEntry)); }
public int Edit([FromBody] WikiEntry wikiEntry) { return(objWikiEntry.UpdateWikiEntry(wikiEntry)); }
public int Create([FromBody] WikiEntry wikiEntry) { return(objWikiEntry.AddWikiEntry(wikiEntry)); }