public ResponseResultType Add(RentRateType rateType, decimal cost) { if (cost < 0) { return(ResponseResultType.ValidationError); } var rentRate = new RentRate { Cost = cost, RentRateType = rateType, CreatedAt = DateTime.Now }; DbContext.RentRates.Add(rentRate); return(SaveChanges()); }
public List <RentRate> MonthlyRentRate(int UserID, DateTime Term) { List <RentRate> data = new List <RentRate>(); SqlDataReader reader = null; try { dBConnection.OpenConnection(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = DBCommandCreator.EXEC(new string[] { "kullaniciID", "term" }, "SP_aylikAracOran"); DBCommandCreator.AddParameter(cmd, "@kullaniciID", DbType.Int32, ParameterDirection.Input, UserID); DBCommandCreator.AddParameter(cmd, "@term", DbType.DateTime, ParameterDirection.Input, DateConverter.ToDatabase(Term)); reader = dBConnection.DataReader(cmd); if (reader.HasRows) { while (reader.Read()) { var temp = new RentRate() { CarID = reader.GetInt32(0), BrandName = reader.GetString(1), CarModel = reader.GetString(2), MonthRate = reader.GetDecimal(3), Term = reader.GetString(4) }; data.Add(temp); } } return(data); } catch (Exception ex) { throw new Exception("An error occured in MonthlyRentRate() func. in SpiceApp.DataAccessLayer.ReportRepository", ex); } finally { if (reader != null) { reader.Close(); } dBConnection.CloseConnection(); } }
public static void PrintRentRate(RentRate rentRate) { Console.WriteLine($"Id: {rentRate.Id} \t Cost: {rentRate.Cost} \t Created at: {rentRate.CreatedAt.ToShortDateString()} \t Rent type: {rentRate.RentRateType}"); }