Пример #1
0
 /// <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);
     }
 }
Пример #2
0
 private static User Mapper(User user, Company company)
 {
     user.Company = company;
     return user;
 }
Пример #3
0
 /// <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>();
     }
 }
Пример #4
0
 /// <summary>
 /// Show the specified company in the edit form.
 /// </summary>
 /// <param name="company"></param>
 public void ShowCompany(Company company)
 {
     Company = company;
 }
Пример #5
0
 private static Contract Mapper(Contract ct, Company cmp, ContractFormula f)
 {
     ct.Company = cmp;
     ct.Formula = f;
     return ct;
 }
Пример #6
0
 /// <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>();
     }
 }
Пример #7
0
 private static Reservation ReservationMapper(
     Reservation reservation, Location location, Company company)
 {
     reservation.Location = location;
     reservation.Company = company;
     return reservation;
 }
Пример #8
0
 private static bool isNew(Company company)
 {
     return company.Id == 0;
 }
Пример #9
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;
     }
 }