예제 #1
0
 public ActionResult CreateEdit(UCountry country)
 {
     if (ModelState.IsValid)
     {
         if (!country._country.Id.Equals(Guid.Empty))
         {
             if (countryService.EditCountry(country._country))
             {
                 ModelState.Clear();
                 country         = new UCountry();
                 ViewBag.Message = Resources.CountryController_String_CountryUpdated;
             }
             else
             {
                 ViewBag.Error = Resources.CountryController_String_CountryNotSaved;
             }
         }
         else
         {
             if (countryService.AddCountry(country._country))
             {
                 ModelState.Clear();
                 country         = new UCountry();
                 ViewBag.Message = Resources.CountryController_String_CountryAdded;
             }
             else
             {
                 ViewBag.Error = Resources.CountryController_String_CountryNotSaved;
             }
         }
     }
     country.CurrencySelect = new SelectList(countryService.CurrencyObj.GetCurrencies(countryProg.Id), "Id", "Name");
     return(ListView());
 }
예제 #2
0
        //
        // GET: CreateEdit
        public ActionResult CreateEdit(string cid)
        {
            UCountry country = new UCountry();

            country.CurrencySelect = new SelectList(countryService.CurrencyObj.GetCurrencies(countryProg.Id), "Id", "Name");

            Guid countryId;

            if (Guid.TryParse(cid, out countryId))
            {
                ViewBag.Action   = "Edit";
                country._country = countryService.GetCountry(countryId);
            }
            return(View(country));
        }