public async Task <IActionResult> PutMusers(int id, Musers musers) { if (id != musers.Id) { return(BadRequest()); } _context.Entry(musers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MusersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Musers> > PostMusers(Musers musers) { _context.Musers.Add(musers); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMusers", new { id = musers.Id }, musers)); }
/* * * public IActionResult CreateUser() * { * if (Request.Method == "POST") * { * String output = "Form submitted<br>"; * String firstname = Request.Form["firstname"]; * output += "Fistname: " + firstname + "<br>"; * String lastname = Request.Form["lastname"]; * output += "Lastname: " + lastname + "<br>"; * String email = Request.Form["email"]; * output += "Email: " + email + "</br>"; * String ipaddress = Request.Form["ipaddress"]; * output += "Ip Address: " + ipaddress + "</br>"; * Response.ContentType = "text/html"; * return Content("<html>" + output + "</html"); * } * else * { * * return View(); * } * } * */ public IActionResult CreateUser() { if (Request.Method == "POST") { String output = "Form submitted and saved successfully<br>"; String firstname = Request.Form["firstname"]; String lastname = Request.Form["lastname"]; String email = Request.Form["email"]; String ipaddress = Request.Form["ipaddress"]; var model = new Musers(); model.Firstname = firstname; model.Lastname = lastname; model.Email = email; model.Ipaddress = ipaddress; model.Gender = "male"; _context.Musers.Add(model); _context.SaveChanges(); Response.ContentType = "text/html"; return(Content("<html>" + output + "</html")); } else { return(View()); } }