public async Task <ActionResult> addUser(DetailUserModel userModel)
        {
            try
            {
                using (HttpClient test = new HttpClient())
                {
                    test.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    HttpResponseMessage res = await test.PostAsJsonAsync("http://localhost:49939/api/gateway/~users/add", userModel);

                    if (res.IsSuccessStatusCode)
                    {
                        var Response = res.Content.ReadAsStringAsync().Result;
                    }
                    else
                    {
                        var Response = res.Content.ReadAsStringAsync().Result;
                        var str      = Newtonsoft.Json.JsonConvert.DeserializeObject <string>(Response);
                        return(View("SorryPage", (object)str));
                    }
                }
            }
            catch
            {
                string str = "Now system is unavailable";
                return(View("SorryPage", (object)str));
            }

            return(View());
        }
Esempio n. 2
0
        public ActionResult Details(long id)
        {
            MainUser        u     = _empRepo.GetById(id);
            DetailUserModel model = UserHelper.MapUserToDetailUserModel(u);

            return(View(model));
        }
        public void TestMethod20()
        {
            var controller = new GatewayController();
            var item       = new DetailUserModel
            {
                FIO         = "Loza Ivan",
                Adress      = "Moscow, Liteynaya d13 kv55",
                Phone       = "89151246578",
                Mark        = "Acura",
                Model       = "MDX",
                StateNumber = "t543mo99",
                NameFine    = "Пересечение стоп линии",
                AmountFine  = 1000
            };
            var result = controller.Post(item).Result;

            Assert.IsNotNull(result);
        }
Esempio n. 4
0
        public static DetailUserModel MapUserToDetailUserModel(MainUser u)
        {
            DetailUserModel model = new DetailUserModel();

            model.Id       = u.Id;
            model.UserName = u.UserName;
            model.UserType = u.UserType.ToString();

            if (u.Details != null)
            {
                model.FirstName   = u.Details.FirstName;
                model.LastName    = u.Details.LastName;
                model.Language    = u.Details.Language;
                model.PhoneNumber = u.Details.PhoneNumber;
                if (u.Details.ShowBirthday)
                {
                    model.BirthDate = u.Details.BirthDate.HasValue ? u.Details.BirthDate.Value.ToString("MMM dd yyyy") : string.Empty;
                }

                model.ShowAge         = u.Details.ShowAge;
                model.ShowBirthday    = u.Details.ShowBirthday;
                model.ShowHobbies     = u.Details.ShowHobbies;
                model.ShowCivilStatus = u.Details.ShowCivilStatus;
                model.ShowAddress     = u.Details.ShowAddress;

                model.Age = u.Details.ShowAge ? u.Details.Age : 0;
                model.HobbiesAndInterest = u.Details.ShowHobbies ? u.Details.HobbiesAndInterest : string.Empty;
                model.CivilStatus        = u.Details.ShowCivilStatus ? u.Details.CivilStatus.ToString() : string.Empty;
                model.Gender             = u.Details.Gender.ToString();
                model.Address            = u.Details.ShowAddress ? u.Details.Address : string.Empty;
                model.Country            = u.Details.Country;
                model.State = u.Details.State;
            }

            return(model);
        }