示例#1
0
 public void AddCountry(Country country)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         context.Countries.Add(country);
         context.SaveChanges();
     }
 }
示例#2
0
 public void AddProvince(Province province)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         context.Entry(province.Country).State = EntityState.Unchanged;
         context.Provinces.Add(province);
         context.SaveChanges();
     }
 }
示例#3
0
 public void DeleteCountry(Country country)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         Country found = context.Countries.Find(country.Id);
         context.Countries.Remove(found);
         context.SaveChanges();
     }
 }
示例#4
0
 public void UpdateCountry(int idToSearch, Country country)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         Country found = context.Countries.Find(idToSearch);
         if (!(string.IsNullOrWhiteSpace(country.Name)))
         {
             found.Name = country.Name;
         }
         found.Code = country.Code;
         context.SaveChanges();
     }
 }