public void SignUpUser(string email, string password) { try { GetUserByEmail(email); } catch (NonExistingUserException exception) { try { User user = new User() { EMAIL = email, PASSWORD = password }; using (var db = new TestTaskDBEntities()) { db.Users.Add(user); db.SaveChanges(); } } catch (Exception e) { throw new Exception(String.Format("Not Able to Add User: {0}", e.Message)); } } }
public UserModel GetUserByEmail(string email) { using (var db = new TestTaskDBEntities()) { var user = db.Users.FirstOrDefault(item => item.EMAIL == email); if (user == null) throw new NonExistingUserException("Given User does not exist"); return (UserModel)userMapper.Map<User>(user); } }
public UserModel GetUserByUserID(int userId) { using (var db = new TestTaskDBEntities()) { var user = db.Users.Find(userId); if (user == null) { throw new NonExistingUserException("Given User does not exist"); } return((UserModel)userMapper.Map <User>(user)); } }
public UserModel GetUserByEmail(string email) { using (var db = new TestTaskDBEntities()) { var user = db.Users.FirstOrDefault(item => item.EMAIL == email); if (user == null) { throw new NonExistingUserException("Given User does not exist"); } return((UserModel)userMapper.Map <User>(user)); } }
public void SaveUserProvince(int userId, int provinceId) { using (var db = new TestTaskDBEntities()) { var user = db.Users.Find(userId); if (user == null) { throw new NonExistingUserException("Given User does not exist"); } user.PROVINCE = Convert.ToInt32(provinceId); db.SaveChanges(); } }
public List<CountryModel> GetCountries() { var countryList = new List<CountryModel>(); using (var db = new TestTaskDBEntities()) { foreach (Country dbCountry in db.Countries) { var country = (CountryModel)countryMapper.Map(dbCountry); countryList.Add(country); } } return countryList; }
public List <CountryModel> GetCountries() { var countryList = new List <CountryModel>(); using (var db = new TestTaskDBEntities()) { foreach (Country dbCountry in db.Countries) { var country = (CountryModel)countryMapper.Map(dbCountry); countryList.Add(country); } } return(countryList); }
public List<ProvinceModel> GetProvinces(int countryId) { var provinceList = new List<ProvinceModel>(); using (var db = new TestTaskDBEntities()) { var provincesInCountry = from provinces in db.Provinces from countryProvinces in provinces.CountryProvinces where countryProvinces.COUNTRY_ID == countryId select provinces; foreach (Province dbProvince in provincesInCountry) { var province = (ProvinceModel)provinceMapper.Map(dbProvince); provinceList.Add(province); } } return provinceList; }
public List <ProvinceModel> GetProvinces(int countryId) { var provinceList = new List <ProvinceModel>(); using (var db = new TestTaskDBEntities()) { var provincesInCountry = from provinces in db.Provinces from countryProvinces in provinces.CountryProvinces where countryProvinces.COUNTRY_ID == countryId select provinces; foreach (Province dbProvince in provincesInCountry) { var province = (ProvinceModel)provinceMapper.Map(dbProvince); provinceList.Add(province); } } return(provinceList); }
public void SaveUserProvince(int userId, int provinceId) { using (var db = new TestTaskDBEntities()) { var user = db.Users.Find(userId); if (user == null) throw new NonExistingUserException("Given User does not exist"); user.PROVINCE = Convert.ToInt32(provinceId); db.SaveChanges(); } }
public UserModel GetUserByUserID(int userId) { using (var db = new TestTaskDBEntities()) { var user = db.Users.Find(userId); if (user == null) throw new NonExistingUserException("Given User does not exist"); return (UserModel)userMapper.Map<User>(user); } }