public int InsertNew(string mFBID, string mName) { NokatEntities entities = new NokatEntities(); Member _Mem = new Member() { FBID = mFBID, Name = mName }; Member MemVar = null; try { MemVar = entities.Members.First(p => p.FBID == mFBID); } catch { entities.Members.AddObject(_Mem); entities.SaveChanges(); return _Mem.ID; } if (MemVar != null) { return MemVar.ID; } else { entities.Members.AddObject(_Mem); entities.SaveChanges(); return _Mem.ID; } }
public string IncreaseRank(int mJokeID) { NokatEntities entities = new NokatEntities(); Joke _Jok = (entities.Jokes.Where(p => p.ID == mJokeID).First()); _Jok.Rank++; _Jok.Good++; entities.SaveChanges(); return _Jok.Rank.Value.ToString() + "_" + _Jok.Good.Value.ToString(); }
public int AddJoke(string mText, int mMemberID) { NokatEntities entities = new NokatEntities(); Joke _Jok = new Joke { JokeText = mText, MemberID = mMemberID,TimeAdded=DateTime.Now.ToUniversalTime() , Rank = 0 , Good= 0 , Bad = 0 }; entities.Jokes.AddObject(_Jok); entities.SaveChanges(); return _Jok.ID; }
public int AddMember(string mName , string mFBID ) { NokatEntities entities = new NokatEntities(); Member _Mem = new Member { Name = mName, FBID = mFBID }; entities.Members.AddObject(_Mem); entities.SaveChanges(); return _Mem.ID; }
public string DecreaseRank(int mJokeID) { NokatEntities entities = new NokatEntities(); //var _rank = --(entities.Jokes.Where(p => p.ID == mJokeID).First().Rank); Joke _Jok = (entities.Jokes.Where(p => p.ID == mJokeID).First()); _Jok.Rank--; _Jok.Bad++; entities.SaveChanges(); return _Jok.Rank.Value.ToString() + "_" + _Jok.Bad.Value.ToString(); }