public async Task<IHttpActionResult> Post(Contact contact) { if (!ModelState.IsValid) { return this.BadRequest(this.ModelState); } return this.Ok(contact); // not persisting, just simulating. }
private List<Contact> AllContacts() { var contacts = new List<Contact>(); // NOTE - The PHONE NUMBER collection is brought in after the fact in JoinObjects() var contact1 = new Contact { ContactId = 123, Name="Asajj Ventress", Subject="I want my light sabers back", Email = "*****@*****.**", Comment="Somebody stole my light sabers and I think it was a Jedi. They snuck up on me from behind.", PhoneNumbers= this.phoneNumberTable.Where(p => p.ContactId.Equals(123)).ToSafeList() }; var contact2 = new Contact { ContactId = 765, Name = "Ashoka Tano", Subject = "A little respect, please", Email = "*****@*****.**", Comment = "Why is that nobody gives me any respect? I've done everything everybody has asked. Oh well.", PhoneNumbers = this.phoneNumberTable.Where(p => p.ContactId.Equals(765)).ToSafeList() }; var contact3 = new Contact { ContactId = 575, Name = "Mother Talzin", Subject = "Anyone see Count Dooku?", Email = "*****@*****.**", Comment = "If anyone sees the Count, let him know I have a new apprentice for him. He will serve him well, much like his brother did for Sideous.", PhoneNumbers = this.phoneNumberTable.Where(p => p.ContactId.Equals(575)).ToSafeList() }; var contact4 = new Contact { ContactId = 852, Name = "Hondo Ohnaka", Subject = "That's for sale, if you are interested", Email = "*****@*****.**", Comment = "So I acquired this space ship; very nice I might say. It would be for sale to you for a very special price.", PhoneNumbers = this.phoneNumberTable.Where(p => p.ContactId.Equals(852)).ToSafeList() }; var contact5 = new Contact { ContactId = 821, Name = "Cad Bane", Subject = "Looking for good hat stores. Know any?", Email = "*****@*****.**", Comment = "I want to be out styling a new look, I'm thinking another hat would get me to the next level. Know of any cool vendors?", PhoneNumbers = this.phoneNumberTable.Where(p => p.ContactId.Equals(821)).ToSafeList() }; var contact6 = new Contact { ContactId = 845, Name = "Fives", Subject = "Dude, they set me up", Email = "*****@*****.**", Comment = "This will sound crazy but I think some brothers have chips that make them more agressive.", PhoneNumbers = this.phoneNumberTable.Where(p => p.ContactId.Equals(845)).ToSafeList() }; contacts.Add(contact1); contacts.Add(contact2); contacts.Add(contact3); contacts.Add(contact4); contacts.Add(contact5); contacts.Add(contact6); return contacts; }