コード例 #1
0
 public ActionResult Create(CountryManagementModel model)
 {
     try
     {
         if (ser.IsCountryExists(model.CountryName) == true)
         {
             TempData["ErrorMessage"] = "Country already exists!";
             return(View("Create", model));
         }
         else if (ser.IsCountryCodeExists(model.CountryCode) == true)
         {
             TempData["ErrorMessage"] = "Country Code already exists!";
             return(View("Create", model));
         }
         else
         {
             ser.CreateCountry(model);
         }
     }
     catch
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
コード例 #2
0
        public ActionResult Edit(int Id)
        {
            CountryManagementModel model = new CountryManagementModel();

            model           = ser.CountryDetail(Id);
            model.CountryId = Id;

            return(View(model));
        }
コード例 #3
0
        public ActionResult Index(int?page)
        {
            int currentPageIndex         = page.HasValue ? page.Value : 1;
            int defaultPageSize          = 30;
            CountryManagementModel model = new CountryManagementModel();

            model.CountryManagementList = ser.ListCountry().ToPagedList(currentPageIndex, defaultPageSize);
            return(View(model));
        }
コード例 #4
0
 public ActionResult Edit(int Id, CountryManagementModel model)
 {
     model.CountryId = Id;
     try
     {
         ser.EditCountry(model);
     }
     catch
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
コード例 #5
0
        public CountryManagementModel CountryDetail(int CountryId)
        {
            Countries result             = ent.Countries.Where(x => x.CountryId == CountryId).FirstOrDefault();
            CountryManagementModel model = new CountryManagementModel();

            model.CountryId     = result.CountryId;
            model.CountryCode   = result.CountryCode;
            model.CountryName   = result.CountryName;
            model.CountryStatus = result.CountryStatus;
            model.Nationality   = result.Nationality;

            return(model);
        }
コード例 #6
0
        public void EditCountry(CountryManagementModel model)
        {
            Countries result = ent.Countries.Where(x => x.CountryId == model.CountryId).FirstOrDefault();

            result.CountryId     = model.CountryId;
            result.CountryCode   = model.CountryCode;
            result.CountryName   = model.CountryName;
            result.CountryStatus = model.CountryStatus;
            result.Nationality   = model.Nationality;

            ent.ApplyCurrentValues(result.EntityKey.EntitySetName, result);
            ent.SaveChanges();
        }
コード例 #7
0
        public void CreateCountry(CountryManagementModel model)
        {
            Countries obj = new Countries
            {
                CountryCode   = model.CountryCode,
                CountryName   = model.CountryName,
                CountryStatus = "A",
                Nationality   = model.Nationality
            };

            ent.AddToCountries(obj);
            ent.SaveChanges();
        }
コード例 #8
0
        public IEnumerable <CountryManagementModel> ListCountry()
        {
            var result = ent.Countries;
            List <CountryManagementModel> model = new List <CountryManagementModel>();

            foreach (var item in result)
            {
                CountryManagementModel obj = new CountryManagementModel
                {
                    CountryId     = item.CountryId,
                    CountryCode   = item.CountryCode,
                    CountryName   = item.CountryName,
                    CountryStatus = item.CountryStatus,
                    Nationality   = item.Nationality
                };
                model.Add(obj);
            }
            return(model.OrderBy(x => x.CountryName));
        }
コード例 #9
0
        public ActionResult Create()
        {
            CountryManagementModel model = new CountryManagementModel();

            return(View(model));
        }