/// <summary> /// Adds the specified saving account type. /// </summary> /// <param name="savingAccountType">Saving account type</param> /// <param name="shouldSaveChanges">if set to <c>true</c> it will save changes to db.</param> /// <returns>Returns newly created saving account type.</returns> public SavingAccountType Add(SavingAccountType savingAccountType, bool shouldSaveChanges = true) { // Checks if saving account type is instantiated if (savingAccountType == null) { throw new ArgumentNullException(nameof(savingAccountType), "Saving account type is not instantiated"); } try { // Adds saving account type instance to database this.context.SavingAccountTypes.Add(savingAccountType); // Saves changes if (shouldSaveChanges) { this.SaveChanges(); } } catch (Exception e) { throw; } return(savingAccountType); }
/// <summary> /// Edits the specified saving account type. /// </summary> /// <param name="savingAccountType">Saving account type</param> /// <param name="shouldSaveChanges">if set to <c>true</c> [should save changes].</param> /// <returns>Returns edited saving account type.</returns> /// <exception cref="ArgumentNullException">Saving account type - saving account type is not instantiated or Id <= 0</exception> public SavingAccountType Edit(SavingAccountType savingAccountType, bool shouldSaveChanges = true) { // Checks if saving account type is instantiated if (savingAccountType == null) { throw new ArgumentNullException(nameof(savingAccountType), "Saving account type is not instantiated"); } try { // Modifies saving account type this.context.Entry(savingAccountType).State = EntityState.Modified; // Saves changes if (shouldSaveChanges) { this.SaveChanges(); } } catch (Exception e) { throw; } return(savingAccountType); }
/// <summary> /// Hides base show method /// </summary> /// <param name="client">The client</param> /// <param name="savingAccountType">Saving account type</param> public new void Show(Client client, SavingAccountType savingAccountType) { this.Client = client; this.SavingAccountType = savingAccountType; // Calls base show method base.Show(); }