예제 #1
0
 protected override void DataOperation()
 {
     using (var db = new retrospyContext())
     {
         if (_recv.ContainsKey("replace"))
         {
             db.Profiles.Where(p => p.Profileid == _session.UserInfo.Profileid &&
                               p.Nick == _recv["oldnick"]).First().Nick = _recv["nick"];
             db.SaveChanges();
         }
         else
         {
             Profiles profiles = new Profiles
             {
                 Profileid = _session.UserInfo.Profileid,
                 Nick      = _recv["nick"],
                 Userid    = _session.UserInfo.Userid
             };
             db.Add(profiles);
         }
     }
 }
예제 #2
0
        protected override void DataOperation()
        {
            using (var db = new retrospyContext())
            {
                if (_request.IsReplaceNickName)
                {
                    var result = from p in db.Profiles
                                 where p.Profileid == _session.UserData.ProfileID &&
                                 p.Nick == _request.OldNick
                                 select p;

                    if (result.Count() != 1)
                    {
                        _errorCode = GPError.DatabaseError;
                    }
                    else
                    {
                        result.First().Nick = _request.NewNick;
                    }

                    db.Profiles.Where(p => p.Profileid == _session.UserData.ProfileID &&
                                      p.Nick == _request.OldNick).First().Nick = _request.NewNick;

                    db.SaveChanges();
                }
                else
                {
                    Profiles profiles = new Profiles
                    {
                        Profileid = _session.UserData.ProfileID,
                        Nick      = _request.NewNick,
                        Userid    = _session.UserData.UserID
                    };

                    db.Add(profiles);
                }
            }
        }