public void AddNewTenant(Tenant tenant, ContactPerson contactPerson, List <Printing> printings) { if ((tenant == null || string.IsNullOrWhiteSpace(tenant.Name) || string.IsNullOrWhiteSpace(tenant.Holding) || string.IsNullOrWhiteSpace(tenant.Email) || string.IsNullOrWhiteSpace(tenant.PhoneNumber) && (contactPerson == null) || string.IsNullOrWhiteSpace(contactPerson.Name) || string.IsNullOrWhiteSpace(contactPerson.Email) || string.IsNullOrWhiteSpace(contactPerson.ContractNumber))) { throw new InvalidOperationException("Tenant And Contact Details is Missing !"); } try { _tenantUnitOfWork.TenantRepository.Add(tenant); _tenantUnitOfWork.ContactPersonRepository.Add(contactPerson); foreach (var item in printings) { item.Tenant = tenant; item.Format = String.Join(",", item.BillFormat); _tenantUnitOfWork.PrintingRepository.Add(item); } //_tenantUnitOfWork.PrintingRepository.Add(printing); _tenantUnitOfWork.Save(); } catch (Exception ex) { _logger.LogError(ex.Message, "Failed to add new tenant"); throw ex; } }
public void AddNewDocument(IList <Document> documents) { foreach (var document in documents) { _tenantUnitOfWork.DocumentRepository.Add(document); } _tenantUnitOfWork.Save(); }