public ActionResult EditPost(string id, TourInfoEditViewModel model)
        {
            ViewBag.PlacesPicklist = this.GetPlacesPicklist();
            if (ModelState.IsValid)
            {
                if (Session["token"] == null)
                {
                    return(RedirectToAction("Index", "Login"));
                }
                string token = Session["token"].ToString();
                // store img to IMGUR first
                List <string> imagesUrl = new List <string>();
                if (model.FileImages.Count() > 0)
                {
                    imagesUrl = AdminHelper.Instance.StoreImagur(model.FileImages);
                }

                var client = connector.Initial();
                client.Timeout = -1;
                var request = new RestRequest("admin/tour-infos/" + id, Method.PUT);
                request.AddHeader("Authorization", "Bearer " + token);
                request.AddHeader("Content-Type", "application/json");
                request.AddJsonBody(new
                {
                    Name             = model.Name,
                    StartPlaceId     = model.StartPlace,
                    DestinatePlaceId = model.DestinatePlace,
                    Images           = JsonConvert.SerializeObject(imagesUrl),
                });

                IRestResponse response = client.Execute(request);
                if (response.IsSuccessful)
                {
                    APIResultModel result = JsonConvert.DeserializeObject <APIResultModel>(response.Content);
                    if (result.ErrorCode != 0)
                    {
                        ViewBag.error = result.Message;
                        return(View());
                    }

                    return(RedirectToAction("Index", "TourInfo"));
                }
                else
                {
                    return(RedirectToAction("Edit", "TourInfo"));
                }
            }
            return(View(model));
        }
        public ActionResult Detail(string id)
        {
            ViewBag.PlacesPicklist = this.GetPlacesPicklist();

            if (id == null)
            {
                return(RedirectToAction("Index", "Place"));
            }

            string token = Session["token"].ToString();

            var client = connector.Initial();

            client.Timeout = -1;
            var request = new RestRequest("admin/tour-infos/" + id, Method.GET);

            request.AddHeader("Authorization", "Bearer " + token);
            IRestResponse response = client.Execute(request);

            TourInfoModel         tourInfo = new TourInfoModel();
            TourInfoEditViewModel model;

            if (response.IsSuccessful)
            {
                var settings = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };
                TourInfoApiResultModel content = JsonConvert.DeserializeObject <TourInfoApiResultModel>(response.Content, settings);
                tourInfo = content.Data[0];
                model    = new TourInfoEditViewModel()
                {
                    Id             = tourInfo.Id,
                    Name           = tourInfo.Name,
                    Images         = tourInfo.Images,
                    Rating         = tourInfo.Rating,
                    StartPlace     = tourInfo.StartPlace.Id,
                    DestinatePlace = tourInfo.DestinatePlace.Id,
                    CreateBy       = tourInfo.CreateBy.Name
                };
                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index", "Place"));
            }
        }