public long FollowChirpR(Domain.Model.ChirpyRUser currentUser, Domain.Model.ChirpyRUser followUser) { using (ChirpyRDataContext context = new ChirpyRDataContext(_connectionName, _schemaName)) { ChirpyRUser cUser = context.ChirpyRUsers.Single<ChirpyRUser>(c => c.UserId == currentUser.UserId); ChirpyRUser fUser = context.ChirpyRUsers.Single<ChirpyRUser>(c => c.UserId == followUser.UserId); ChirpyRRelation relation = new ChirpyRRelation { Parent = cUser, Child = fUser }; context.Entry<ChirpyRRelation>(relation).State = System.Data.EntityState.Added; return relation.Id; } }
public long FollowChirpR(Domain.Model.ChirpyRUser currentUser, Domain.Model.ChirpyRUser followUser) { using (ChirpyRDataContext context = new ChirpyRDataContext(_connectionName, _schemaName)) { ChirpyRUser cUser = context.ChirpyRUsers.Single <ChirpyRUser>(c => c.UserId == currentUser.UserId); ChirpyRUser fUser = context.ChirpyRUsers.Single <ChirpyRUser>(c => c.UserId == followUser.UserId); ChirpyRRelation relation = new ChirpyRRelation { Parent = cUser, Child = fUser }; context.Entry <ChirpyRRelation>(relation).State = System.Data.EntityState.Added; return(relation.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); }
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; }