コード例 #1
0
        public HttpResponseMessage OrdersHistory([Description("Номер чит билета")] int ReaderId)
        {
            CirculationInfo         Circulation = new CirculationInfo();
            List <OrderHistoryInfo> result      = new List <OrderHistoryInfo>();

            try
            {
                result = Circulation.GetOrdersHistory(ReaderId);
            }
            catch (Exception ex)
            {
                return(ALISErrorFactory.CreateError(ex.Message, Request));
            }
            return(ALISResponseFactory.CreateResponse(result, Request));
        }
コード例 #2
0
        public static void Register(HttpConfiguration config)
        {
            //// Uncomment the following to use the documentation from XML documentation file.
            config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/Documentation/documentation.xml")));

            //// Uncomment the following to use "sample string" as the sample for all actions that have string as the body parameter or return type.
            //// Also, the string arrays will be used for IEnumerable<string>. The sample objects will be serialized into different media type
            //// formats by the available formatters.
            //config.SetSampleObjects(new Dictionary<Type, object>
            //{
            //    {typeof(string), "sample string"},
            //    {typeof(IEnumerable<string>), new string[]{"sample 1", "sample 2"}}
            //});

            // Extend the following to provide factories for types not handled automatically (those lacking parameterless
            // constructors) or for which you prefer to use non-default property values. Line below provides a fallback
            // since automatic handling will fail and GeneratePageResult handles only a single type.
#if Handle_PageResultOfT
            config.GetHelpPageSampleGenerator().SampleObjectFactories.Add(GeneratePageResult);
#endif

            // Extend the following to use a preset object directly as the sample for all actions that support a media
            // type, regardless of the body parameter or return type. The lines below avoid display of binary content.
            // The BsonMediaTypeFormatter (if available) is not used to serialize the TextSample object.
            config.SetSampleForMediaType(
                new TextSample("Binary JSON content. See http://bsonspec.org for details."),
                new MediaTypeHeaderValue("application/bson"));

            //// Uncomment the following to use "[0]=foo&[1]=bar" directly as the sample for all actions that support form URL encoded format
            //// and have IEnumerable<string> as the body parameter or return type.
            //config.SetSampleForType("[0]=foo&[1]=bar", new MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(IEnumerable<string>));

            //// Uncomment the following to use "1234" directly as the request sample for media type "text/plain" on the controller named "Values"
            //// and action named "Put".
            //config.SetSampleRequest("1234", new MediaTypeHeaderValue("text/plain"), "Values", "Put");

            //// Uncomment the following to use the image on "../images/aspNetHome.png" directly as the response sample for media type "image/png"
            //// on the controller named "Values" and action named "Get" with parameter "id".
            //config.SetSampleResponse(new ImageSample("../images/aspNetHome.png"), new MediaTypeHeaderValue("image/png"), "Values", "Get", "id");

            //// Uncomment the following to correct the sample request when the action expects an HttpRequestMessage with ObjectContent<string>.
            //// The sample will be generated as if the controller named "Values" and action named "Get" were having string as the body parameter.
            //config.SetActualRequestType(typeof(string), "Values", "Get");

            //// Uncomment the following to correct the sample response when the action returns an HttpResponseMessage with ObjectContent<string>.
            //// The sample will be generated as if the controller named "Values" and action named "Post" were returning a string.
            //config.SetActualResponseType(typeof(string), "Values", "Post");


            ReaderInfo reader = ReaderInfo.GetReader(189245);
            //Readers.Get
            ReaderSimpleView rsv  = ReaderViewFactory.GetReaderSimpleView(reader);
            string           json = JsonConvert.SerializeObject(rsv, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "Get");


            //Readers.GetByOauthToken
            AccessToken token = new AccessToken();
            token.TokenValue = "jhgfjfg*%&$*FKGfkfKfI^(*&^5&^TGVfjtgfdtre$E65r86T87t)(*7goYGV986T98^&Go8yg";
            json             = JsonConvert.SerializeObject(token, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "GetByOauthToken");

            json = JsonConvert.SerializeObject(rsv, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "GetByOauthToken");

            ////Readers.ChangePasswordLocalReader
            //ChangePasswordLocalReader password = new ChangePasswordLocalReader();
            //password.DateBirth = "1984-02-14";// new DateTime(1984, 2, 14);
            //password.NewPassword = "******";
            //password.NumberReader = 189245;
            //json = JsonConvert.SerializeObject(password, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            //config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "ChangePasswordLocalReader");

            //Readers.GetLoginType
            LoginType ltype = new LoginType();
            ltype.LoginTypeValue = "Email";
            json = JsonConvert.SerializeObject(ltype, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "GetLoginType");
            UserLogin ul = new UserLogin();
            ul.Login = "******";
            json     = JsonConvert.SerializeObject(ul, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "GetLoginType");


            //Readers.ByEmail
            UserEmail ue = new UserEmail();
            ue.Email = "*****@*****.**";
            json     = JsonConvert.SerializeObject(ue, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "ByEmail");
            json = JsonConvert.SerializeObject(rsv, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "ByEmail");



            //Readers.Authorize
            AuthorizeInfo aut = new AuthorizeInfo();
            aut.login    = "******";
            aut.password = "******";
            json         = JsonConvert.SerializeObject(aut, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "Authorize");
            config.SetSampleForType(aut, new MediaTypeHeaderValue("application/json"), typeof(AuthorizeInfo));
            config.SetActualRequestType(typeof(AuthorizeInfo), "Readers", "Authorize");
            json = JsonConvert.SerializeObject(rsv, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "Authorize");

            //Readers / IsBirthDateMatchReaderId
            BirthDateMatchReaderId match = new BirthDateMatchReaderId();
            match.DateBirth = "1984-02-14";
            match.ReaderId  = 189245;
            BooleanResponse br = new BooleanResponse();
            br.Result = true;
            json      = JsonConvert.SerializeObject(match, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "IsBirthDateMatchReaderId");
            json = JsonConvert.SerializeObject(br, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "IsBirthDateMatchReaderId");

            //Readers/SetPasswordLocalReader
            SetPasswordLocalReader spwd = new SetPasswordLocalReader();
            spwd.NewPassword = "******";
            spwd.ReaderId    = 189245;
            json             = JsonConvert.SerializeObject(spwd, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "SetPasswordLocalReader");


            //Books.Get
            BookSimpleView book;
            book = ViewFactory.GetBookSimpleView("BJVVV_1411951");
            json = JsonConvert.SerializeObject(book, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Books", "Get");

            //Circulation.InsertIntoUserBasket
            ImpersonalBasket basket = new ImpersonalBasket();
            basket.BookIdArray = new List <string>();
            basket.BookIdArray.AddRange(new string[] { "BJVVV_1299121", "BJVVV_1304618", "REDKOSTJ_31866", "REDKOSTJ_43090" });
            basket.ReaderId = 189245;
            json            = JsonConvert.SerializeObject(basket, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Circulation", "InsertIntoUserBasket");

            //Circulation.Basket
            CirculationInfo   circ       = new CirculationInfo();
            List <BasketInfo> UserBasket = circ.GetBasket(888);
            json = JsonConvert.SerializeObject(UserBasket, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Circulation", "Basket");

            //Circulation.Order
            circ = new CirculationInfo();
            MakeOrder mo = new MakeOrder();
            mo.BookId      = "BJVVV_1078762";
            mo.ReaderId    = 100000;
            mo.OrderTypeId = 2;
            json           = JsonConvert.SerializeObject(mo, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Circulation", "Order");


            //Circulation.Orders
            List <OrderInfo> UserOrders = circ.GetOrders(155);
            json = JsonConvert.SerializeObject(UserOrders, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Circulation", "Orders");
            //Circulation.Basket    Delete
            BasketDelete bd = new BasketDelete();
            bd.BooksToDelete.Add("BJVVV_1299121");
            bd.BooksToDelete.Add("BJVVV_1491232");
            bd.ReaderId = 200500;
            json        = JsonConvert.SerializeObject(bd, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Circulation", "DeleteFromBasket");

            //Circulation.OrdersHistory
            List <OrderHistoryInfo> UserOrdersHistory = circ.GetOrdersHistory(100000);
            json = JsonConvert.SerializeObject(UserOrdersHistory, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Circulation", "OrdersHistory");


            //Readers.PreRegisterRemoteReader
            PreRegisterRemoteReader re = new PreRegisterRemoteReader();
            re.BirthDate   = "1975-05-05";//new DateTime(1975, 05, 05);
            re.CountryId   = 137;
            re.Email       = "*****@*****.**";
            re.FamilyName  = "Иванов";
            re.FatherName  = "Иванович";
            re.MobilePhone = "89551234567";
            re.Name        = "Иван";
            re.Password    = "******";
            json           = JsonConvert.SerializeObject(re, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "PreRegisterRemoteReader");

            //Readers.ConfirmRegistrationRemoteReader
            ConfirmRegistrationRemoteReader c = new ConfirmRegistrationRemoteReader();
            c.Url = "https://oauth.libfl.ru/activate/<activation code>";
            json  = JsonConvert.SerializeObject(c, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "ConfirmRegistrationRemoteReader");

            //Readers.ChangePasswordByEmail
            ChangePasswordByEmail em = new ChangePasswordByEmail();
            em.Email = "*****@*****.**";
            json     = JsonConvert.SerializeObject(em, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "ChangePasswordByEmail");

            //Readers.SetPasswordRemoteReader
            SetPasswordRemoteReader set = new SetPasswordRemoteReader();
            set.Url      = "https://oauth.libfl.ru/recovery/<recovery code>";
            set.Password = "******";
            json         = JsonConvert.SerializeObject(set, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "SetPasswordRemoteReader");

            //Readers.CheckPasswordUrl
            CheckPasswordUrl check = new CheckPasswordUrl();
            check.Url = "https://oauth.libfl.ru/recovery/<recovery code>";
            json      = JsonConvert.SerializeObject(check, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "CheckPasswordUrl");

            //GET Litres/Account/{ReaderId}
            LitresInfo li = new LitresInfo();
            li.Login    = "******";
            li.Password = "******";
            json        = JsonConvert.SerializeObject(li, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Litres", "LitresAccount");
            //POST Litres/AssignAccount/{ReaderId}
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Litres", "AssignLitresAccount");


            //Circulation / Orders / ById /{ OrderId}
            OrderInfo oi = circ.GetOrder(22);
            json = JsonConvert.SerializeObject(oi, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Circulation", "OrdersById");

            //Books/ElectronicCopy/{id}
            ElectronicCopyFullView ec = ViewFactory.GetElectronicCopyFullView("BJVVV_138023");
            json = JsonConvert.SerializeObject(ec, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Books", "GetElectronicCopyFullView");
        }