DocumentDBRepository.Initialize C# (CSharp) Метод

Initialize() публичный статический Метод

public static Initialize ( ) : void
Результат void
        public static void Initialize()
        {
            client = new DocumentClient(new Uri(ConfigurationManager.AppSettings["endpoint"]), ConfigurationManager.AppSettings["authKey"], new ConnectionPolicy { EnableEndpointDiscovery = false });
            CreateDatabaseIfNotExistsAsync().Wait();
            CreateCollectionIfNotExistsAsync().Wait();
        }
        private static async Task CreateDatabaseIfNotExistsAsync()

Usage Example

Пример #1
0
        public async Task <HttpResponseMessage> Post([FromBody] JToken jsonbody)//[FromBody] FormDocument form) //FormDocument form)
        {
            //FormDocument form = new FormDocument();
            DocumentDBRepository.Initialize();
            Document doc;
            //string c = await Request.Content.ReadAsStringAsync();
            //Console.Write(c);
            JTokenReader jtReader = new JTokenReader(jsonbody);
            dynamic      form     = JObject.Parse(jsonbody.ToString());

            //form.LoadFrom(jtReader);
            //form.formType = jsonbody.Value<string>("ftype");
            //form.formVersion = jsonbody.Value<string>("ver");
            form.timeStamp = DateTime.Now;
            //form.data = jsonbody.Value<string>("data");
            form.creator = Request.GetRequestContext().Principal.Identity.Name;
            form.status  = ConfigurationManager.AppSettings["defaultStatus"];

            try {
                //doc = await DocumentDBRepository.CreateItemAsync(jsonbody);
                doc = await DocumentDBRepository.CreateItemAsync(form);
            }
            catch  {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            HttpResponseMessage r = Request.CreateResponse(HttpStatusCode.OK, doc.Id);

            r.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            return(r);
        }
All Usage Examples Of DocumentDBRepository::Initialize