コード例 #1
0
        public ActionResult Edit(string id)
        {
            var model = new CityViewModel();
            model.Countries = HealthHelper.GetAllCountries();

            if (id != "-1")
            {
                var svc = new GeoCityAppService();
                var o = svc.GetGeoCity(id);
                model.GeoCityId = o.GeoCityId;
                model.GeoCountryId = o.GeoState.GeoCountryId;
                model.Name = o.Name;
                model.GeoStateId = o.GeoStateId;
                model.Latitude = o.Latitude;
                model.Longitude = o.Longitude;

            }
            else
            {


                model.Action = "-1";
                model.GeoCityId = string.Empty;
                model.Name = string.Empty;
                model.GeoStateId = "-1";
                model.Latitude = 0;
                model.Longitude = 0;
            }



            return View(model);
        }
コード例 #2
0
        public ActionResult Edit(CityViewModel model)
        {

            model.Countries = HealthHelper.GetAllCountries();
            try
            {
                var svc = new GeoCityAppService();

                var o = new GeoCity
                {
                    GeoCityId = model.GeoCityId,
                    Name = model.Name,
                    GeoStateId = model.GeoStateId,
                    Latitude = model.Latitude,
                    Longitude = model.Longitude

                };

                if (model.Action == "-1")
                {
                    var exist = svc.GetGeoCity(model.GeoCityId) != null;
                    if (!exist)
                    {

                        svc.AddGeoCity(o);

                    

                        ViewBag.Feed = 0;
                    }
                    else
                    {
                        model.Action = "-1";
                        ViewBag.Feed = 3;
                        return View(model);
                    }
                }
                else
                {
                    o.GeoCityId = model.GeoCityId;
                    if (model.IsDeleteAction == 0)
                    {

                        svc.SaveGeoCity(o);
                    }
                    else
                    {
                        svc.RemoveGeoCity(model.GeoCityId);
                    }
                    ViewBag.Feed = 0;
                }
            }
            catch (Exception)
            {
                ViewBag.Feed = 1;

            }

            return View(model);
        }