/// <summary> /// Delete the specified company. /// </summary> /// <param name="company">The company to be deleted</param> /// <returns>Number of affected rows.</returns> public static int Delete(Company company) { using (SqlConnection connection = SamenSterkerDB.GetConnection()) { return connection.Execute(deleteQuery, company); } }
private static User Mapper(User user, Company company) { user.Company = company; return user; }
/// <summary> /// Get all the users of the specified company. /// </summary> /// <param name="company">The company of which the users /// are requested.</param> /// <returns>The users of the specified company.</returns> public static List<User> GetFromCompany(Company company) { using (SqlConnection connection = SamenSterkerDB.GetConnection()) { return connection.Query<User, Company, User>( sql: selectAllQuery + "WHERE CompanyId = @CompanyId", map: Mapper, param: new { CompanyId = company.Id } ).ToList<User>(); } }
/// <summary> /// Show the specified company in the edit form. /// </summary> /// <param name="company"></param> public void ShowCompany(Company company) { Company = company; }
private static Contract Mapper(Contract ct, Company cmp, ContractFormula f) { ct.Company = cmp; ct.Formula = f; return ct; }
/// <summary> /// Get all contracts of the specified company. /// </summary> /// <param name="company">The company of which the contracts are requested</param> /// <returns>The contracts of the specified company.</returns> public static List<Contract> GetFromCompany(Company company) { using (SqlConnection connection = SamenSterkerDB.GetConnection()) { return connection.Query<Contract, Company, ContractFormula, Contract>( sql: selectAllQuery + "WHERE CompanyId = @Id", map: Mapper, param: company ).ToList<Contract>(); } }
private static Reservation ReservationMapper( Reservation reservation, Location location, Company company) { reservation.Location = location; reservation.Company = company; return reservation; }
private static bool isNew(Company company) { return company.Id == 0; }
/// <summary> /// Save the specified company. /// </summary> /// <param name="company">The company to be saved.</param> /// <returns>Number of affected rows.</returns> public static int Save(Company company) { using (SqlConnection connection = SamenSterkerDB.GetConnection()) { int rowsAffected = connection.Execute( sql: isNew(company) ? insertCommand : updateCommand, param: company ); //SetIdentity<int>(connection, id => subCategory.Id = id); return rowsAffected; } }