-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from StevenKight/feature/rent-furniture
Feature/rent furniture
- Loading branch information
Showing
22 changed files
with
2,103 additions
and
586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
RentMeFurnitureRentalSystem/RentMeFurnitureRentalSystem/DAL/RentalDAL.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using Dapper; | ||
using MySql.Data.MySqlClient; | ||
using RentMeFurnitureRentalSystem.model; | ||
using RentMeFurnitureRentalSystem.Model; | ||
|
||
namespace RentMeFurnitureRentalSystem.DAL; | ||
|
||
public class RentalDAL | ||
{ | ||
|
||
public static RentalItem GetRentalById(int id) | ||
{ | ||
using var connection = new MySqlConnection(Connection.ConnectionString); | ||
connection.Open(); | ||
|
||
var results = connection.Query<RentalItem>(QueryStrings.GetRentalById, new { Id = id }); | ||
|
||
return results.ElementAt(0); | ||
} | ||
|
||
public static List<RentalItem> GetRentalItems(int rentalId) | ||
{ | ||
using var connection = new MySqlConnection(Connection.ConnectionString); | ||
connection.Open(); | ||
|
||
var results = connection.Query<RentalItem>(QueryStrings.GetRentalItems, new { Id = rentalId }); | ||
|
||
return results.ToList(); | ||
} | ||
|
||
public static decimal GetRentalTotal(int rentalId) | ||
{ | ||
using var connection = new MySqlConnection(Connection.ConnectionString); | ||
connection.Open(); | ||
|
||
var results = connection.QuerySingle<decimal>(QueryStrings.GetRentalTotal, new { Id = rentalId }); | ||
|
||
return results; | ||
} | ||
|
||
public static int GetRentalId(RentalItem rental) | ||
{ | ||
using var connection = new MySqlConnection(Connection.ConnectionString); | ||
connection.Open(); | ||
|
||
var result = connection.Query<int>(QueryStrings.GetRentalId, rental); | ||
|
||
try | ||
{ | ||
return result.ElementAt(0); | ||
} | ||
catch | ||
{ | ||
return -1; | ||
} | ||
} | ||
|
||
public static bool CreateRental(RentalItem rental) | ||
{ | ||
using var connection = new MySqlConnection(Connection.ConnectionString); | ||
connection.Open(); | ||
|
||
var affected = connection.Execute(QueryStrings.CreateRental, rental); | ||
|
||
return affected > 0; | ||
} | ||
|
||
public static bool CreateRentalItem(RentalItem rentalItem) | ||
{ | ||
using var connection = new MySqlConnection(Connection.ConnectionString); | ||
connection.Open(); | ||
|
||
var affected = connection.Execute(QueryStrings.CreateRentalItem, rentalItem); | ||
|
||
return affected > 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...RentalSystem/Properties/DataSources/RentMeFurnitureRentalSystem.Model.Customer.datasource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
This file is automatically generated by Visual Studio. It is | ||
used to store generic object data source configuration information. | ||
Renaming the file extension or editing the content of this file may | ||
cause the file to be unrecognizable by the program. | ||
--> | ||
<GenericObjectDataSource DisplayName="Customer" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> | ||
<TypeInfo>RentMeFurnitureRentalSystem.Model.Customer, RentMeFurnitureRentalSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo> | ||
</GenericObjectDataSource> |
10 changes: 10 additions & 0 deletions
10
...RentalSystem/Properties/DataSources/RentMeFurnitureRentalSystem.model.Employee.datasource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
This file is automatically generated by Visual Studio. It is | ||
used to store generic object data source configuration information. | ||
Renaming the file extension or editing the content of this file may | ||
cause the file to be unrecognizable by the program. | ||
--> | ||
<GenericObjectDataSource DisplayName="Employee" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> | ||
<TypeInfo>RentMeFurnitureRentalSystem.model.Employee, RentMeFurnitureRentalSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo> | ||
</GenericObjectDataSource> |
10 changes: 10 additions & 0 deletions
10
...entalSystem/Properties/DataSources/RentMeFurnitureRentalSystem.model.Furniture.datasource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
This file is automatically generated by Visual Studio. It is | ||
used to store generic object data source configuration information. | ||
Renaming the file extension or editing the content of this file may | ||
cause the file to be unrecognizable by the program. | ||
--> | ||
<GenericObjectDataSource DisplayName="Furniture" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> | ||
<TypeInfo>RentMeFurnitureRentalSystem.model.Furniture, RentMeFurnitureRentalSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo> | ||
</GenericObjectDataSource> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
RentMeFurnitureRentalSystem/RentMeFurnitureRentalSystem/model/RentalItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace RentMeFurnitureRentalSystem.model | ||
{ | ||
public class RentalItem | ||
{ | ||
public int Member_id { get; set; } | ||
public int Employee_num { get; set; } | ||
public DateTime Start_date { get; set; } | ||
public DateTime Due_date { get; set; } | ||
public int Furniture_id { get; set; } | ||
public int Quantity { get; set; } | ||
} | ||
} |
Oops, something went wrong.