Ejemplo n.º 1
0
        public ActionResult Edit(string id)
        {
            var model = new StateViewModel();
            model.Countries = HealthHelper.GetAllCountries();



            if (id != "-1")
            {
                var svc = new GeoStateAppService();
                var o = svc.GetGeoState(id);
                model.GeoCountryId = o.GeoCountryId;
                model.Name = o.Name;
                model.GeoStateId = o.GeoStateId;
                model.Latitude = o.Latitude;
                model.Longitude = o.Longitude;
                
            }
            else
            {
                model.Action = "-1";
                model.Name = string.Empty;
                model.Latitude = 0;
                model.Longitude = 0;
            }



            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(StateViewModel model)
        {
            model.Countries = HealthHelper.GetAllCountries();

            try
            {
                var svc = new GeoStateAppService();

                var o = new GeoState
                {
                    GeoStateId = model.GeoStateId,
                    Name = model.Name,
                    GeoCountryId = model.GeoCountryId,
                    Latitude = model.Latitude,
                    Longitude = model.Longitude

                };

                if (model.Action == "-1")
                {
                    var exist = svc.GetGeoState(model.GeoStateId) != null;
                    if (!exist)
                    {
                        svc.AddGeoState(o);
                        ViewBag.Feed = 0;
                    }
                    else
                    {
                        model.Action = "-1";
                        ViewBag.Feed = 3;
                        return View(model);
                    }
                }
                else
                {
                    o.GeoStateId = model.GeoStateId;
                    if (model.IsDeleteAction == 0)
                    {

                        svc.SaveGeoState(o);
                    }
                    else
                    {
                        svc.RemoveGeoState(model.GeoStateId);
                    }
                    ViewBag.Feed = 0;
                }
            }
            catch (Exception)
            {
                ViewBag.Feed = 1;

            }

            return View(model);
        }