示例#1
0
        private static byte[] FakeOccupies(BigInteger serverId, string email, BigInteger cityID)
        {
            if (Runtime.CheckWitness(Owner))
            {
                if (cityID > Const.numCities || cityID <= 0)
                {
                    return(NuTP.RespDataWithCode(ErrCate.City, ErrType.NotExist));
                }
                else
                {
                    User user = RW.FindUser(email);
                    if (user != null)
                    {
                        City city = RW.FindCity(serverId, cityID);
                        if (city.ownerID.Length == 0 || city.ownerID.Length == 1) //something wrong with bytes2string/string2bytes
                        {                                                         //not work when it's not occupied
                            city.ownerID = email;
                            RW.SaveCity(serverId, city);

                            user.city = cityID;
                            RW.SaveUser(user);
                            return(NuTP.RespDataSuccess());
                        }
                        else
                        {
                            return(NuTP.RespDataWithCode(ErrCate.City, ErrType.Duplicated));
                        }
                    }
                    else
                    {
                        return(NuTP.RespDataWithCode(ErrCate.User, ErrType.NotExist));
                    }
                }
            }
            else
            {
                return(NuTP.RespDataWithCode(ErrCate.Account, ErrType.AuthFail));
            }
        }