public IActionResult CreateNewLease(LeasesDTO newLease) { newLease.LeaseAgreementDate = DateTime.Today; var addNewLease = _repo.AddLease(newLease); return(Ok(addNewLease)); }
public IEnumerable <Lease> AddLease(LeasesDTO newLease) { using (var db = new SqlConnection(_connectionString)) { var sql = @"INSERT INTO [Leases] ([leaseAgreementDate] ,[leaseStartDate] ,[rentalFee] ,[rentDueDate] ,[userId] ,[hasPet] ,[petFee] ,[rentalId] ,[securityDeposit] ,[bankNameForDeposit] ,[tenantId] ,[lateFee] ,[holdOver] ,[holdOverFee] ,[Notes] ) output inserted.* VALUES (@leaseAgreementDate ,@leaseStartDate ,@rentalFee ,@rentDueDate ,@userId ,@hasPet ,@petFee ,@rentalId ,@securityDeposit ,@bankNameForDeposit ,@tenantId ,@lateFee ,@holdOver ,@holdOverFee ,@Notes)"; return(db.Query <Lease>(sql, newLease)); } }