public IHttpActionResult PutCreditApplication(Guid id, CreditApplication creditApplication)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != creditApplication.Id)
            {
                return BadRequest();
            }

            _creditApplicationService.Find(x => x.Id == id).FirstOrDefault().EntityState = State.Modified;

            try
            {
                _creditApplicationService.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CreditApplicationExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult PostCreditApplication(CreditApplicationModel creditApplicationModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            var creditApplication = new CreditApplication();
            try
            {
                creditApplication = _mapper.MapCreditApplicationModel(creditApplicationModel);
                creditApplication.SendingDate = DateTime.Now;
                _creditApplicationService.Add(creditApplication);
                _creditApplicationService.SaveChanges();
            }
            catch (Exception ex)
            {
                _logService.Log(LoggingHelper.CreateErrorLog(HttpContext.Current, ex));
                return BadRequest(ex.Message);
            }

            return Ok(new
            {
                id = creditApplication.Id,
            });
        }
        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"));
        }