コード例 #1
0
ファイル: RestService.cs プロジェクト: DeagleGross/SushiApp
        /// <summary>
        /// Checks the data type version.
        /// </summary>
        /// <returns>The data type version.</returns>
        /// <param name="type">Type.</param>
        /// <param name="version">Version.</param>
        public async Task <string> CheckDataTypeVersion(string type, string version)
        {
            if (!CheckConnection)
            {
                return("-404");
            }

            DataVersion data    = new DataVersion(type, version, 1);
            RestRequest request = new RestRequest("versionchecker", Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddBody(SerializationHelper.SerializeToJson(data));

            var response = await client.ExecuteTaskAsync(request);

            if (response.StatusCode == HttpStatusCode.InternalServerError)
            {
                return("-404");
            }

            string serverResponse = JsonConvert.DeserializeObject <string>(response.Content);

            // error 404 means no type was found; error 0 means wtf???
            if (serverResponse == "404" || serverResponse == "0")
            {
                return("0"); // ERROR TYPE
            }
            else
            {
                return(serverResponse);
            }
        }
コード例 #2
0
 public int SaveVersion(DataVersion data)
 {
     lock (locker)
     {
         if (database.Find <DataVersion>(data.Id) == data || data.Id <= 0)
         {
             return(0);
         }
         else
         {
             return(database.Insert(data));
         }
     }
 }