public void Student_AddTest() { StudentViewModel vm = new StudentViewModel { FirstName = "Jean-Luc", LastName = "Desjardins", PhoneNo = "(555)555-1234", Title = "Mr.", DivisionId = 10, Email = "*****@*****.**" }; vm.Add(); Assert.True(vm.id > 0); }
public IHttpActionResult Post(StudentViewModel stu) { try { stu.Add(); if (stu.Id > 0) { return(Ok("Student " + stu.Lastname + " added!")); } else { return(Ok("Student" + stu.Lastname + " not added!")); } } catch (Exception ex) { return(BadRequest("Creation failed - Contact Tech Support")); } }