public IHttpActionResult CreateStudent(StudentDto studentDto) { if (!ModelState.IsValid) { return(BadRequest()); } var student = Mapper.Map <StudentDto, Student1>(studentDto); context.Students.Add(student); context.SaveChanges(); studentDto.Id = student.Id; return(Created(new Uri(Request.RequestUri + "/" + student.Id), studentDto)); }
public ActionResult Create(Student1 student) { if (ModelState.IsValid) { context.Student1s.Add(student); context.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }