public IActionResult Post([FromBody] User user) { _context.Add(user); _context.SaveChanges(); return(CreatedAtRoute("GetById", new { id = user.UserId }, user)); }
public ActionResult <IEnumerable <string> > Get() { _model.Name = "Raj Pawar"; _model.Email = "*****@*****.**"; _context.Add(_model); _context.SaveChanges(); return(new string[] { "value1", "value2" }); }
public async Task <IActionResult> Create([Bind("Id,fName,lName,mName")] Person person) { if (ModelState.IsValid) { _context.Add(person); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(person)); }
public async Task <IActionResult> Create([Bind("tagName,description")] Tag tag) { if (ModelState.IsValid) { _context.Add(tag); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tag)); }
public async Task <IActionResult> Create([Bind("authorId,bio")] Author author) { if (ModelState.IsValid) { _context.Add(author); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(author)); }
public async Task <IActionResult> Create([Bind("Id,isbn,title,authorId")] Book book) { if (ModelState.IsValid) { _context.Add(book); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["authorId"] = new SelectList(_context.authors, "authorId", "authorId", book.authorId); return(View(book)); }
public IActionResult CreateUser([FromBody] User user) { _context.Add(user); _context.SaveChanges(); return(CreatedAtRoute(nameof(GetUserById), new { id = user.id }, user)); }
public IActionResult CreateParking([FromBody] Parking parking) { _context.Add(parking); _context.SaveChanges(); return(CreatedAtRoute(nameof(GetParking), new { id = parking.id }, parking)); }