internal static void EnsureAuthorExists(String authorEmail, out AuthorLINQ authorLinq, String message, MinimaServiceLINQDataContext db) { Func <AuthorLINQ, Boolean> authorExists = x => x.AuthorEmail == authorEmail; authorLinq = db.Authors.SingleOrDefault(authorExists); if (authorLinq == null) { throw new ArgumentException(message); } }
public String CreateAuthor(String authorEmail, String authorName) { using (DataContext db = new DataContext(ServiceConfiguration.ConnectionString)) { String authorGuid = String.Empty; if (!db.Authors.Any(p => p.AuthorEmail == authorEmail)) { AuthorLINQ authorLinq = new AuthorLINQ(); authorLinq.AuthorEmail = authorEmail; authorLinq.AuthorName = authorName; authorLinq.AuthorGuid = Themelia.GuidCreator.GetNewGuid(); authorLinq.AuthorCreateDate = DateTime.Now; //+ db.Authors.InsertOnSubmit(authorLinq); db.SubmitChanges(); //+ authorGuid = authorLinq.AuthorGuid; } //+ return(authorGuid); } }
//- ~EnsureAuthorExists -// internal static void EnsureAuthorExists(String authorEmail, out AuthorLINQ authorLinq, MinimaServiceLINQDataContext db) { EnsureAuthorExists(authorEmail, out authorLinq, Message.InvalidEmail, db); }