コード例 #1
0
 public CountryVM EditCountry(CountryVM c)
 {
     DB.tblCountry country = IMSDB.tblCountries.Find(c.CountryId);
     if (country != null)
     {
         country.CountryName        = c.CountryName;
         country.CountryCode        = c.CountryCode;
         country.IsActive           = c.IsActive;
         IMSDB.Entry(country).State = EntityState.Modified;
         IMSDB.SaveChanges();
     }
     return(c);
 }
コード例 #2
0
 public CountryVM AddCountry(CountryVM c)
 {
     DB.tblCountry country = IMSDB.tblCountries.Add(
         new DB.tblCountry
     {
         CountryCode = c.CountryCode,
         CountryName = c.CountryName,
         IsActive    = c.IsActive
     });
     IMSDB.SaveChanges();
     c.CountryId = country.CountryId;
     return(c);
 }
コード例 #3
0
        public CountryVM GetCountryById(int countryId)
        {
            DB.tblCountry country = IMSDB.tblCountries.Where(p => p.CountryId == countryId).FirstOrDefault();
            if (country != null)
            {
                return(new CountryVM()
                {
                    CountryId = country.CountryId,
                    CountryName = country.CountryName,
                    CountryCode = country.CountryCode,
                    IsActive = country.IsActive
                });
            }

            return(null);
        }