コード例 #1
0
        public bool CreateBooking(BookingModel model)
        {
            try
            {
                string json = Serialize(model);
                HttpResponseMessage responseContent = requestMethod.PostAndGetContent(string.Format("{0}CreateBooking", restService), json);
                if (responseContent.StatusCode == HttpStatusCode.Created)
                {
                    var createdCarnetAttachmentModel = Deserialize <BookingModel>(responseContent.Content.ReadAsStringAsync().Result);
                    return(true);
                }
                else if (responseContent.StatusCode == HttpStatusCode.BadRequest)
                {
                    modelStateErrors = Deserialize <ReturnErrorModel>(responseContent.Content.ReadAsStringAsync().Result);
                    return(false);
                }
                else if (responseContent.StatusCode == HttpStatusCode.InternalServerError)
                {
                    modelExceptionErrors = Deserialize <ExceptionHandler>(responseContent.Content.ReadAsStringAsync().Result);
                    string message = String.Format("System Error in {0} : {1} ", System.Reflection.MethodBase.GetCurrentMethod().Name, modelExceptionErrors.exceptionMessage);
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }