예제 #1
0
        public async Task <ActionResult> UploadResults(string processing_accesstoken, string uuid, string result, string newState)
        {
            if (!await this.checkProcessingPermissions(processing_accesstoken))
            {
                return(this.Error("UploadResults Denied"));
            }
            if (string.IsNullOrWhiteSpace(uuid))
            {
                return(this.Error("UploadResults Denied: invalid parameter uuid"));
            }
            if (string.IsNullOrWhiteSpace(result))
            {
                return(this.Error("UploadResults Denied: invalid parameter result"));
            }

            var wasSuccessfullyModified = false;

            try
            {
                var reading = new LibreReadingModel
                {
                    ModifiedOn = DateTime.Now,
                    status     = "complete",
                    uuid       = uuid,
                    result     = result,
                    newState   = newState
                };

                wasSuccessfullyModified = await MongoConnection.AsyncUpdateReading(reading);
            }
            catch (Exception ex)
            {
                return(Error("UploadResults Failed: " + ex.Message));
            }

            return(Success <string>($"Modified: {wasSuccessfullyModified}", "UploadResults"));
            //var content = $"processing_accesstoken: {processing_accesstoken}, uuid: {uuid}, result: {result}";
            //return Content(System.Reflection.MethodBase.GetCurrentMethod().Name + " IS NOT IMPLEMENTED YET:" + content);
        }