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" });
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
 public IActionResult CreateUser([FromBody] User user)
 {
     _context.Add(user);
     _context.SaveChanges();
     return(CreatedAtRoute(nameof(GetUserById), new { id = user.id }, user));
 }
Exemplo n.º 8
0
 public IActionResult CreateParking([FromBody] Parking parking)
 {
     _context.Add(parking);
     _context.SaveChanges();
     return(CreatedAtRoute(nameof(GetParking), new { id = parking.id }, parking));
 }