Пример #1
0
        /// <summary>
        /// Edits the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>ActionResult.</returns>
        public ActionResult Edit(string id)
        {
            var model = new CountryViewModel();

            if (id != "-1")
            {
                var svc = new GeoCountryAppService();
                var o = svc.GetGeoCountry(id);
                model.GeoCountryId = o.GeoCountryId;
                model.Name = o.Name;
                model.Latitude = o.Latitude;
                model.Longitude = o.Longitude;

            }
            else
            {
                model.Action = "-1";
                model.GeoCountryId = string.Empty;
                model.Name = string.Empty;
                model.Latitude = 0;
                model.Longitude = 0;
            }



            return View(model);
        }
Пример #2
0
        public ActionResult Edit(CountryViewModel model)
        {



            try
            {
                var svc = new GeoCountryAppService();

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

                };

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

                        svc.SaveGeoCountry(o);
                    }
                    else
                    {
                        svc.RemoveGeoCountry(model.GeoCountryId);
                    }
                    ViewBag.Feed = 0;
                }
            }
            catch (Exception)
            {
                ViewBag.Feed = 1;

            }

            return View(model);
        }