Example #1
0
        public void CreateExhibitByApi(Exhibit exhibit)
        {
            Logger.Log("<- exhibit: " + exhibit, LogType.MessageWithoutScreenshot);
            DataContractJsonSerializer exhibitSerializer = new DataContractJsonSerializer(typeof(Exhibit));
            DataContractJsonSerializer guidSerializer    = new DataContractJsonSerializer(typeof(NewExhibitApiResponse));

            exhibit.Timeline_ID = new Guid(CosmosGuidTemplate);

            HttpWebRequest request       = MakePutRequest(ExhibitApiServiceUrl);
            Stream         requestStream = request.GetRequestStream();

            exhibitSerializer.WriteObject(requestStream, exhibit);
            WebResponse response       = request.GetResponse();
            Stream      responseStream = response.GetResponseStream();

            if (responseStream == null)
            {
                throw new NullReferenceException("responseStream is null");
            }

            NewExhibitApiResponse newExhibitApiResponse = (NewExhibitApiResponse)guidSerializer.ReadObject(responseStream);

            exhibit.Id = new Guid(newExhibitApiResponse.ExhibitId);
            Logger.Log("->");
        }
Example #2
0
        public NewExhibitApiResponse CreateExhibitByApi(Exhibit exhibit)
        {
            DataContractJsonSerializer exhibitSerializer = new DataContractJsonSerializer(typeof(Exhibit));
            DataContractJsonSerializer guidSerializer    = new DataContractJsonSerializer(typeof(NewExhibitApiResponse));

            exhibit.Timeline_ID = new Guid(CosmosGuidTemplate);

            //using (MemoryStream ms = new MemoryStream())
            //{
            //    exhibitSerializer.WriteObject(ms, exhibit);
            //    var ttt = Encoding.Default.GetString(ms.ToArray());
            //}

            HttpWebRequest request       = MakePutRequest(ExhibitApiServiceUrl);
            Stream         requestStream = request.GetRequestStream();

            exhibitSerializer.WriteObject(requestStream, exhibit);
            WebResponse response       = request.GetResponse();
            Stream      responseStream = response.GetResponseStream();

            if (responseStream == null)
            {
                throw new NullReferenceException("responseStream is null");
            }

            NewExhibitApiResponse newExhibitApiResponse = (NewExhibitApiResponse)guidSerializer.ReadObject(responseStream);

            return(newExhibitApiResponse);
        }
Example #3
0
        public NewExhibitApiResponse CreateExhibitByApi(Exhibit exhibit)
        {
            DataContractJsonSerializer exhibitSerializer = new DataContractJsonSerializer(typeof(Exhibit));
            DataContractJsonSerializer guidSerializer    = new DataContractJsonSerializer(typeof(NewExhibitApiResponse));

            exhibit.Timeline_ID = new Guid(CosmosGuidTemplate);

            HttpWebRequest request       = MakePutRequest(ExhibitApiServiceUrl);
            Stream         requestStream = request.GetRequestStream();

            exhibitSerializer.WriteObject(requestStream, exhibit);
            WebResponse response       = request.GetResponse();
            Stream      responseStream = response.GetResponseStream();

            if (responseStream == null)
            {
                throw new NullReferenceException("responseStream is null");
            }

            NewExhibitApiResponse newExhibitApiResponse = (NewExhibitApiResponse)guidSerializer.ReadObject(responseStream);

            return(newExhibitApiResponse);
        }