//below function for console only // public Tenant AddATenant(long tenantId, string firstName, string lastName, string address, string postalCode, string city, string idProof, double deposit, bool isAssigned){ // return _tenantStorageList.CreateATenant(tenantId, firstName, lastName, address, postalCode, city, idProof, deposit, isAssigned); // } //added for webApi public Assignment CreateAssignment(Guid tenantId, int unitNum) { var tenant = _tenantStorageList.GetById(tenantId); tenant.Assign(); var unit = _rentalStorageList.GetByUnitNum(unitNum); unit.Assign(); var assignment = new Assignment(unit, tenant); _assignStorageList.Create(assignment); assignment.IsAssigned = true; return(assignment); }
//below function for console only // public Tenant AddATenant(long tenantId, string firstName, string lastName, string address, string postalCode, string city, string idProof, double deposit, bool isAssigned){ // return _tenantStorage.CreateATenant(tenantId, firstName, lastName, address, postalCode, city, idProof, deposit, isAssigned); // } //added for webApi public Assignment CreateAssignment(Guid tenantId, Guid rentalId) { var tenant = _tenantStorage.GetById(tenantId); tenant.Assign(); _tenantStorage.Update(tenant); var unit = _rentalStorage.GetById(rentalId); unit.Assign(); _rentalStorage.Update(unit); var assignment = new Assignment(unit, tenant) { Rental = unit, Tenant = tenant, IsAssigned = true }; _assignStorage.Create(assignment); return(assignment); }