Ejemplo n.º 1
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);
        }