Пример #1
0
 public void signup(User entity)
 {
     using (PropertyHubContext context = new PropertyHubContext())
     {
         context.Entry(entity.Role).State = EntityState.Unchanged;
         context.Add(entity);
         context.SaveChanges();
     }
 }
 public Province AddProvince(Province province)
 {
     using (PropertyHubContext context = new PropertyHubContext())
     {
         context.Entry(province.Country).State = EntityState.Unchanged;
         context.Add(province);
         context.SaveChanges();
     }
     return(province);
 }
 public City AddCity(City city)
 {
     using (PropertyHubContext context = new PropertyHubContext())
     {
         context.Entry(city.Province).State = EntityState.Unchanged;
         context.Add(city);
         context.SaveChanges();
     }
     return(city);
 }
 public City UpdateCity(int idToSearch, City city)
 {
     using (PropertyHubContext context = new PropertyHubContext())
     {
         context.Entry(city.Province).State = EntityState.Unchanged;
         City found = context.Find <City>(idToSearch);
         found.Name     = (!string.IsNullOrWhiteSpace(city.Name)) ? city.Name : found.Name;
         found.Province = (city.Province != null && city.Province.Id > 0) ? city.Province : found.Province;
         context.SaveChanges();
         return(found);
     }
 }