/// <summary> /// Creates new Account. /// </summary> /// <param name="accountInfo"></param> /// <returns></returns> public async Task <int> CreateAccount(LoginDTO accountInfo) { try { using (var context = new OplatyEntities()) { var _client = new Klienci() { Imie = accountInfo.Name, Nazwisko = accountInfo.LastName, PESEL = accountInfo.PESEL, Haslo = accountInfo.Password }; try { context.Klienci.Add(_client); int _res = await context.SaveChangesAsync(); return(_res); } catch (Exception) { throw; } } } catch (Exception) { throw; } }
/// <summary> /// Sets new password. /// </summary> /// <param name="accountID"></param> /// <param name="pass"></param> /// <returns></returns> public async Task <int> SetsNewPassword(int accountID, byte[] pass) { using (var context = new OplatyEntities()) { try { var account = context.Klienci.SingleOrDefault(x => x.KlientID == accountID); if (account != null) { account.Haslo = pass; } int _result = await context.SaveChangesAsync(); return(_result); } catch (ArgumentNullException) { throw new ArgumentNullException("Your account isn't available."); } catch (InvalidOperationException) { throw new InvalidOperationException("You can't do this operation"); } catch (Exception) { throw; } } }