Exemple #1
0
        public static AggregateView GetCurrentReleaseFromFile()
        {
            var import = new Import();
            if (File.Exists(HttpContext.Current.Server.MapPath(import.YouTrackJsonFile)) == false)
                import.SaveAllToFile();

            var allText = File.ReadAllText(HttpContext.Current.Server.MapPath(import.YouTrackJsonFile));

            var data = new JavaScriptSerializer().Deserialize<List<AggregateView>>(allText);
            var result = data.First(x => x.currentRelease);

            return result;
        }
        public void PostCreditApplication()
        {
            var userName = "******";
            var password = "******";
            var tokenResponse = HttpClient.PostAsync("/token",
                new FormUrlEncodedContent(new []
                {
                    new KeyValuePair<string, string>("grant_type", "password"),
                    new KeyValuePair<string, string>("username", userName),
                    new KeyValuePair<string, string>("password", password)
                })).Result;
            var tokenBodyValues = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(tokenResponse.Content.ReadAsStringAsync().Result);

            var creditTypeResponse = HttpClient.GetAsync("/api/creditTypes").Result;
            var creditTypes = new JavaScriptSerializer().Deserialize<List<CreditTypeModel>>(creditTypeResponse.Content.ReadAsStringAsync().Result);
            var creditApplication = new CreditApplication()
            {
                DesiredAmount = 100000,
                DesiredTerm = 12,
                CreditAim = "sdfsdfsd",

                AptNumber = 2,
                CorpusNumber = 2,
                HomeNumber = 2,
                Locality = "Минская Область",
                Street = "Богдановича",

                MaritalStatus = "холост",
                EducationLevel = "незаконченное высшее",
                NumberOfFamilyMembers = 5,
                NumberOfDependents = 0,

                BirthDate = new DateTime(1993, 12, 8),
                DateOfIssue = DateTime.Now,
                PassportNumber = "MP1231724",
                PersonalNumber = "3081293A005PB9",
                PlaceOfBirth = "Минск, Беларусь",
                PlaceOfIssue = "Фрунзенское РУВД г.Минска",

                FirstName = "Максим",
                LastName = "Рахлеев",
                MiddleName = "Александрович",
                MobilePhone = "375295053587",
                Email = "*****@*****.**",

                CompanyName = "ФордэКонсалтинг",
                Position = ".Net Developer",
                Activity = "sdfsdf",
                DateOfBeginning = new DateTime(2015, 4, 23),
                Profit = 200000000,

                Status = CreditApplicationStatus.InQueue,
                DeclineReason = String.Empty,
                ClientId = tokenBodyValues["user_id"],
                CreditTypeId = creditTypes.First().Id
            };
            var stringContent = new JavaScriptSerializer().Serialize(creditApplication);
            var creditApplicationResponse = HttpClient.PostAsync("/api/creditApplications",
                new StringContent(new JavaScriptSerializer().Serialize(creditApplication), Encoding.Unicode, "application/json")).Result;
            var creditApplicationBodyValues = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(creditApplicationResponse.Content.ReadAsStringAsync().Result);
            Assert.That(creditApplicationBodyValues.ContainsKey("id"));
        }