Transmission ITransmissionApi.CreateTransmission(string targetInboxId) { if (targetInboxId == null) { throw new ArgumentNullException("TargetInboxId"); } var targetInbox = inboxApi.GetInbox(targetInboxId); if (targetInbox == null) { throw new ArgumentException("TargetInbox does not exist."); //TODO: Need an exception infrastructure. } Transmission transmission = new Transmission { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, TargetInbox = targetInbox }; context.Transmissions.Add(transmission); context.SaveChanges(); //TODO: Who handles the exceptions? return(transmission); }
void IInboxFunctionsSampleApi.CreateInbox(Inbox inbox) { if (inbox.Id == null || inbox.Id.Length == 0) { throw new ArgumentException(); //TODO: Maybe use a different exception type? Need to distinguish it from "inboxAlreadyExists". } var existingInbox = context.Inboxes.Find(inbox.Id); if (existingInbox != null) { throw new ArgumentException(); } inbox.ApiKey = generateApiKey(); context.Inboxes.Add(inbox); context.SaveChanges(); //TODO: Who handles the exceptions? }