public List <Country> GetCountries() { using (PropertyHubContext context = new PropertyHubContext()) { return((from c in context.Countries select c).ToList()); } }
public void signup(User entity) { using (PropertyHubContext context = new PropertyHubContext()) { context.Entry(entity.Role).State = EntityState.Unchanged; context.Add(entity); context.SaveChanges(); } }
public List <City> GetCities() { using (PropertyHubContext context = new PropertyHubContext()) { return((from c in context.Cities .Include(c => c.Province.Country) select c).ToList()); } }
public Country AddCountry(Country country) { using (PropertyHubContext context = new PropertyHubContext()) { context.Add(country); context.SaveChanges(); } return(country); }
public Country GetCountry(int id) { using (PropertyHubContext context = new PropertyHubContext()) { return((from c in context.Countries where c.Id == id select c).FirstOrDefault()); } }
public List <Role> GetRoles() { PropertyHubContext context = new PropertyHubContext(); using (context) { return((from u in context.Roles select u).ToList()); } }
public List <User> GetUsers() { using (PropertyHubContext context = new PropertyHubContext()) { return((from u in context.Users .Include("Role") .Include("Address.City.Province.Country") select u).ToList()); } }
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 DeleteCity(int id) { using (PropertyHubContext context = new PropertyHubContext()) { City found = context.Find <City>(id); context.Remove(found); context.SaveChanges(); return(found); } }
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 List <Province> GetProvinces(Country country) { using (PropertyHubContext context = new PropertyHubContext()) { return((from p in context.Provinces .Include(p => p.Country) where p.Country.Id == country.Id select p).ToList()); } }
public City GetCity(int id) { using (PropertyHubContext context = new PropertyHubContext()) { return((from c in context.Cities .Include(c => c.Province.Country) where id == c.Id select c).FirstOrDefault()); } }
public User GetUser(string apikey) { using (PropertyHubContext context = new PropertyHubContext()) { return((from u in context.Users .Include("Role") .Include("Address.City.Province.Country") where u.ApiKey.Equals(apikey) select u).FirstOrDefault()); } }
public User GetUser(string loginid, string password) { using (PropertyHubContext context = new PropertyHubContext()) { return((from u in context.Users .Include("Role") .Include("Address.City.Province.Country") where u.LoginId.Equals(loginid) && u.Password.Equals(password) select u).FirstOrDefault()); } }
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); } }
public Country UpdateCountry(int idToSearch, Country country) { using (PropertyHubContext context = new PropertyHubContext()) { Country found = context.Find <Country>(idToSearch); //context.Update(country); if (!string.IsNullOrWhiteSpace(country.Name)) { found.Name = country.Name; } if (country.Code != null && country.Code > 0) { found.Code = country.Code; } context.SaveChanges(); return(found); } }