Exemplo n.º 1
0
 public void AddCountry(Country country)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         context.Countries.Add(country);
         context.SaveChanges();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
     }
 }