public long RegisterUser(Domain.Model.ChirpyRUser newUser) { Data.Model.ChirpyRUser user = new Model.ChirpyRUser() .LoadFromDomainEntity(newUser); using (ChirpyRDataContext context = new ChirpyRDataContext(_connectionName, _schemaName)) { context.Entry <ChirpyRUser>(user).State = System.Data.EntityState.Added; context.SaveChanges(); } return(user.Id); }
public long AddChirp(Domain.Model.Chirp chirp) { using (ChirpyRDataContext context = new ChirpyRDataContext(_connectionName, _schemaName)) { Data.Model.Chirp replyChirp = chirp.InReplyTo != null ? context.Chirps.Find(chirp.InReplyTo.Id) : null; Data.Model.ChirpyRUser chirpUser = chirp.ChirpBy != null ? context.ChirpyRUsers.Find(chirp.ChirpBy.Id) : null; Data.Model.Chirp newChirp = new Model.Chirp(); newChirp.LoadFromDomainEntity(chirp); context.Entry<Data.Model.Chirp>(newChirp).State = System.Data.EntityState.Added; context.SaveChanges(); return newChirp.Id; } }
public long AddChirp(Domain.Model.Chirp chirp) { using (ChirpyRDataContext context = new ChirpyRDataContext(_connectionName, _schemaName)) { Data.Model.Chirp replyChirp = chirp.InReplyTo != null? context.Chirps.Find(chirp.InReplyTo.Id) : null; Data.Model.ChirpyRUser chirpUser = chirp.ChirpBy != null? context.ChirpyRUsers.Find(chirp.ChirpBy.Id) : null; Data.Model.Chirp newChirp = new Model.Chirp(); newChirp.LoadFromDomainEntity(chirp); context.Entry <Data.Model.Chirp>(newChirp).State = System.Data.EntityState.Added; context.SaveChanges(); return(newChirp.Id); } }
public long RegisterUser(Domain.Model.ChirpyRUser newUser) { Data.Model.ChirpyRUser user = new Model.ChirpyRUser() .LoadFromDomainEntity(newUser); using (ChirpyRDataContext context = new ChirpyRDataContext(_connectionName, _schemaName)) { context.Entry<ChirpyRUser>(user).State = System.Data.EntityState.Added; context.SaveChanges(); } return user.Id; }