public IActionResult edit(int id)
        {
            CountryModel          model = new LocationsHandler().GetCountry(id).ToModel();
            List <SelectListItem> temp  = new LocationsHandler().GetCountries().ToSelectListItems();

            temp.Find(x => Convert.ToInt32(x.Value) == model.Id).Selected = true;
            ViewData["countries"] = temp;
            return(PartialView("~/Views/Country/_edit.cshtml", model));
        }
Beispiel #2
0
 public override void Entry(IModHelper helper)
 {
     helper.Events.GameLoop.GameLaunched += SetCompatOptions;
     LocationsHandler     = new LocationsHandler(helper);
     MapExtrasHandler     = new MapExtrasHandler(helper);
     SpouseRoomHandler    = new SpouseRoomHandler(helper);
     FestivalSpotsHandler = new FestivalSpotsHandler(helper);
     TileActionsHandler   = new TileActionsHandler(helper);
     helper.Content.AssetLoaders.Add(new GameAssetLoader(helper));
 }
        public IActionResult addCountry()
        {
            User currentUser = HttpContext.Session.Get <User>(WebUtil.CURRENT_USER);

            if (!(currentUser?.Role?.Id == WebUtil.ADMIN))
            {
                return(RedirectToAction("login", "users", new { Controller = "Country", Action = "addCountry" }));
            }
            List <CountryModel> models = new LocationsHandler().GetCountries().ToModelList();

            return(View(models));
        }
Beispiel #4
0
 public IActionResult Delete(int id)
 {
     try
     {
         Country entity = new LocationsHandler().DeleteCountry(id);
         return(Ok(entity));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
Beispiel #5
0
 public IActionResult Put(int id, CountryModel model)
 {
     try
     {
         Country entity = new LocationsHandler().UpdateCountry(id, model.ToEntity());
         return(Ok(entity));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
Beispiel #6
0
 public IActionResult Post(CountryModel model)
 {
     try
     {
         Country entity = new LocationsHandler().AddCountry(model.ToEntity());
         return(Created($"/api/Country/{entity.Id}", entity));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
Beispiel #7
0
 public IActionResult Get()
 {
     try
     {
         List <CountryModel> models = new LocationsHandler().GetCountries().ToModelList();
         return(Ok(models));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
Beispiel #8
0
 public IActionResult Get(int id)
 {
     try
     {
         CountryModel model = new LocationsHandler().GetCountry(id).ToModel();
         return(Ok(model));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
        public IActionResult Delete(int id)
        {
            User currentUser = HttpContext.Session.Get <User>(WebUtil.CURRENT_USER);

            if (!(currentUser?.Role?.Id == WebUtil.ADMIN))
            {
                return(RedirectToAction("login", "users", new { Controller = "Country", Action = "addCountry" }));
            }

            CountryModel model = new LocationsHandler().GetCountries(id).ToModel();

            return(PartialView("~/views/Country/delete.cshtml", model));
        }
Beispiel #10
0
        public IActionResult Edit(int id)
        {
            User currentUser = HttpContext.Session.Get <User>(WebUtil.CURRENT_USER);

            if (!(currentUser?.Role?.Id == WebUtil.ADMIN))
            {
                return(RedirectToAction("login", "users", new { Controller = "City", Action = "AddCities" }));
            }
            CityModel             model = new LocationsHandler().GetCities(id).ToModel();
            List <SelectListItem> items = new LocationsHandler().GetProvinces(new Country()).ToSelectItemList();

            items.Find(x => Convert.ToInt32(x.Value) == model.Province.Id).Selected = true;
            ViewBag.items = items;
            return(PartialView("~/views/city/_edit.cshtml", model));
        }
Beispiel #11
0
        public IActionResult Edit(int id)
        {
            if (!IsAdmin)
            {
                return(Redirect("~/users/login?ctl=neighborhood&act=manage"));
            }
            NeighborhoodModel     model = new PropertyHubHandler().GetNeighborhood(id).ToModel();
            List <SelectListItem> items = new LocationsHandler().GetCities(new Country {
                Id = 1
            }).ToItems();

            items.Find(x => Convert.ToInt32(x.Value) == model.City.Id).Selected = true;
            ViewData["Cities"] = items;
            return(PartialView("~/views/neighborhood/_edit.cshtml", model));
        }
Beispiel #12
0
        public IActionResult Edit(int id)
        {
            User currentUser = HttpContext.Session.Get <User>(WebUtil.CURRENT_USER);

            if (!(currentUser?.Role?.Id == WebUtil.ADMIN))
            {
                return(RedirectToAction("login", "users", new { Controller = "Neighbourhood", Action = "Manage" }));
            }

            NeighborhoodModel     model = new PropertyAdvsHandler().GetNeighborhood(id).ToModel();
            List <SelectListItem> items = new LocationsHandler().GetCities(new Country {
                Id = 2
            }).ToSelectItemList();

            items.Find(x => Convert.ToInt32(x.Value) == model.City.Id).Selected = true;
            ViewBag.Cities = items;
            return(PartialView("~/views/neighbourhood/_edit.cshtml", model));
        }
Beispiel #13
0
        public IActionResult Create()
        {
            if (!IsAdmin)
            {
                return(Redirect("~/users/login?ctl=neighborhood&act=manage"));
            }
            List <SelectListItem> items = new List <SelectListItem> {
                new SelectListItem {
                    Text = "- Select City -", Value = "0"
                }
            };
            List <City> cities = new LocationsHandler().GetCities(new Country {
                Id = 1
            });

            items.AddRange(new LocationsHandler().GetCities(new Country {
                Id = 1
            }).ToItems());
            ViewData["Cities"] = items;
            return(PartialView("~/views/neighborhood/_create.cshtml"));
        }
Beispiel #14
0
        public async Task <IHttpActionResult> Post()
        {
            var     req  = Request.Content.ReadAsStreamAsync().Result;
            var     json = new StreamReader(req).ReadToEnd();
            dynamic x    = JsonConvert.DeserializeObject(json);

            foreach (dynamic entry in (JArray)x.entry)
            {
                foreach (JObject eve in (JArray)entry.messaging)
                {
                    await MessageHandler.SendTypingNotification((string)eve["sender"]["id"]);

                    if (eve["postback"] != null)
                    {
                        PostbackHandler.EntryPoint(eve["postback"]["payload"]);
                    }
                    else if (eve["message"]["attachments"] != null)
                    {
                        if ((string)eve["message"]["attachments"][0]["type"] == "location")
                        {
                            var id     = (string)eve["sender"]["id"];
                            var coords = eve["message"]["attachments"][0]["payload"]["coordinates"];
                            var lng    = (double)coords["long"];
                            var lat    = (double)coords["lat"];

                            LocationsHandler.UpdateUserLocation(id, $"{lat},{lng}");
                        }
                    }
                    else
                    {
                        await SendMessage((string)eve["message"]["text"], (string)eve["sender"]["id"]);
                    }
                }
            }

            return(Ok());
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            //using (PropertyHubContext context=new PropertyHubContext())
            //{
            //    //Create
            //    //context.Add(new Country { Code = 92, Name = "Pakistan" });
            //    //context.Add(new Country { Code = 1, Name = "USA" });
            //    //context.Add(new Country { Code = 86, Name = "China" });
            //    //context.SaveChanges();

            //    //Retrieve
            //    //Country c = (from c in context.Countries where c.Id == 1 select c).FirstOrDefault();
            //    //List<Country> result = (from c in context.Countries select c).ToList();
            //    //List<Country> result = (from c in context.Countries where c.Code < 100 select c).ToList();
            //    //List<Country> result = context.Countries.ToList();
            //    //Country found = context.Find<Country>(1);

            //    //Update
            //    //Country found = context.Find<Country>(1);
            //    //found.Name = "New Name";
            //    //found.Code = 111;
            //    //context.SaveChanges();

            //    //Delete
            //    //Country found = context.Find<Country>(1);
            //    //context.Remove(found);
            //    //context.SaveChanges();

            //    //var result = from c in context.Countries select c;
            //    //foreach (var r in result)
            //    //{
            //    //    Console.WriteLine($"{r.Code}\t{r.Name}");
            //    //}

            //    Province p = new Province();
            //    p.Name = "Punjab";
            //    p.Cities.Add(new City { Name = "Lahore" });
            //    p.Cities.Add(new City { Name = "Faisalabad" });
            //    p.Country = context.Find<Country>(4);
            //    //p.Country = new Country { Id = 4 };
            //    //context.Entry(p.Country).State = EntityState.Unchanged;
            //    context.Add(p);
            //    context.SaveChanges();

            //}


            LocationsHandler temp = new LocationsHandler();
            Country          pk   = new Country {
                Id = 4
            };

            temp.AddProvince(new Province {
                Name = "Sindh", Country = pk
            });
            temp.AddProvince(new Province {
                Name = "KPK", Country = pk
            });
            temp.AddProvince(new Province {
                Name = "Baluchistan", Country = pk
            });

            List <Province> provinces = temp.GetProvinces();

            foreach (var p in provinces)
            {
                Console.WriteLine(p.Name);
            }

            Console.WriteLine("Done.");
            Console.ReadKey();
        }
        public IActionResult delete(int id)
        {
            CountryModel model = new LocationsHandler().GetCountry(id).ToModel();

            return(PartialView("~/Views/Country/_delete.cshtml", model));
        }