// GET: api/Person/5 public Person Get(int personId) { var person = new Person() { PersonID = personId, FirstName = "Amir", LastName = "Riwes" }; return person; }
// POST: api/Registration public long Post([FromBody]RegistrationDTO request) { int changesSaved = 0; try { using (var dbContext = new WeddingSiteBuilderEntities()) { var person = new Person() { Email = request.Email, Password = request.Password, FirstName = request.FirstName, LastName = request.LastName }; dbContext.People.Add(person); var wedding = new Wedding(); dbContext.Weddings.Add(wedding); changesSaved = dbContext.SaveChanges(); var attendee = new Attendee() { WeddingID = wedding.WeddingID, PersonID = person.PersonID, WeddingRole = request.BrideOrGroom == "Bride" ? "Bride" : "Groom", Side = request.BrideOrGroom == "Bride" ? "Bride" : "Groom" }; dbContext.Attendees.Add(attendee); changesSaved += dbContext.SaveChanges(); if(changesSaved == 3) { return wedding.WeddingID; } else { return 0; } } } catch(Exception) { return 0; } }