Esempio n. 1
0
        public string AddNewOffice(string token, AddOfficeDto addOfficeDto)
        {
            using (var client = new HttpClient())
            {
                AddOfficeModel = new AddOfficeModel()
                {
                    Id                = 0,
                    CityId            = addOfficeDto.CityId,
                    OfficeName        = addOfficeDto.OfficeName,
                    StartDate         = DateTime.Now.ToString("d.M.yyyy hh:mm"),
                    EndDate           = DateTime.Now.ToString("d.M.yyyy hh:mm"),
                    OfficeStatusValue = 1,
                    Phone1            = addOfficeDto.Phone1,
                    Address           = addOfficeDto.Address,
                    CountyId          = addOfficeDto.CountyId,
                    IsApi             = true.ToString()
                };



                var modelConv = JsonConvert.SerializeObject(AddOfficeModel).Replace("\"", "\'");

                AddOfficeParameters = new AddOfficeParameters()
                {
                    Model = modelConv
                };
                //var addOfficeParConv = JsonConvert.SerializeObject(AddOfficeParameters);

                var obj = new AddOfficeLoginObject()
                {
                    Controller          = "Office",
                    Action              = "AddOffice",
                    Method              = "POST",
                    AddOfficeListFilter = AddOfficeParameters
                };

                var addOfficeListFilter = JsonConvert.SerializeObject(obj).Replace("\\", String.Empty);


                var content = new StringContent(addOfficeListFilter, Encoding.UTF8, "application/json");

                if (!string.IsNullOrWhiteSpace(token))
                {
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", string.Format("Bearer {0}", token));
                }

                var response = client.PostAsync("http://appapi.anahtarfinans.com/api/route/execute", content).Result;
                var result   = response.Content.ReadAsStringAsync().Result;
                return(result);
            }
        }
Esempio n. 2
0
 public DataAccessPort()
 {
     AddOfficeModel = new AddOfficeModel();
 }