public void EditTenant_WhenTenantAndContactPerson_EditTenantContactPersonObject()
        {
            //Arragne
            var tenant        = new Tenant();
            var contactPerson = new ContactPerson();

            tenant.Id                     = 1;
            tenant.Name                   = "Jalal Uddin";
            tenant.Holding                = "9-B/2";
            tenant.PhoneNumber            = "01521200542";
            tenant.Email                  = "*****@*****.**";
            tenant.AdvanceArrear          = 250000;
            tenant.Rent                   = 25000;
            tenant.ServiceCharge          = 1200;
            tenant.WaterBill              = 500;
            tenant.ContractExpirationDate = new DateTime(2020, 4, 18);
            tenant.ContractSigningDate    = new DateTime(2022, 4, 27);
            tenant.Status                 = true;
            tenant.ContactPersons         = new List <ContactPerson>()
            {
                new ContactPerson
                {
                    Id             = 1,
                    Name           = "Shahed",
                    Email          = "*****@*****.**",
                    ContractNumber = "01521200544"
                },
            };
            tenant.Printings = new List <Printing>()
            {
                new Printing
                {
                    Id     = 9,
                    Format = "Rent,GasBill",
                    Tenant = tenant
                },
            };
            string[]        billType  = new string[] { "rent", "electricityBill" };
            List <Printing> printings = new List <Printing>()
            {
                new Printing
                {
                    Id         = 9,
                    Format     = "Rent,GasBill",
                    BillFormat = billType,
                    Tenant     = tenant
                },
            };

            _tenantUnitOfWorkMock.Setup(x => x.TenantRepository).Returns(_tenantRepositoryMock.Object);
            _tenantUnitOfWorkMock.Setup(x => x.PrintingRepository).Returns(_printingRepositoryMock.Object);
            _tenantRepositoryMock.Setup(x => x.GetTenantIncludingChild(tenant.Id)).Returns(tenant).Verifiable();
            _tenantUnitOfWorkMock.Setup(x => x.Save()).Verifiable();
            //Act
            _tenantService.EditTenant(tenant, contactPerson, printings);
            //Assert
            _tenantRepositoryMock.VerifyAll();
            _tenantUnitOfWorkMock.VerifyAll();
        }
Пример #2
0
 public IActionResult Edit(Models.Journals.EditJournalModel model)
 {
     if (ModelState.IsValid)
     {
         _tenantService.EditTenant(new ViewModels.Journals.EditJournalModel
         {
             JournalId    = model.JournalId,
             IsActive     = model.IsActive,
             JournalName  = model.JournalName,
             JournalTitle = model.JournalTitle
         }, model.Logo?.OpenReadStream(), model.Logo?.FileName);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Пример #3
0
 public void EditTenant()
 {
     try
     {
         var tenant = new Tenant
         {
             Id                     = this.Id,
             Name                   = this.Name,
             Holding                = this.Holding,
             PhoneNumber            = this.PhoneNumber,
             Email                  = this.Email,
             AdvanceArrear          = this.AdvanceArrear,
             Rent                   = this.Rent,
             GasBill                = this.GasBill,
             ServiceCharge          = this.ServiceCharge,
             WaterBill              = this.WaterBill,
             ContractStartDate      = this.ContractStartDate,
             ContractExpirationDate = this.ContractExpirationDate,
             PaymentType            = this.PaymentType
         };
         var contactPerson = new ContactPerson
         {
             Id             = this.TenantId,
             Name           = this.ContactPersonName,
             Email          = this.ContactPersonEmail,
             ContractNumber = this.ContactPersonContractNumber
         };
         _tenantService.EditTenant(tenant, contactPerson, Printings);
         Notification = new NotificationModel("Success!", "Tenant Successfully Updated", NotificationModel.NotificationType.Success);
     }
     catch (InvalidOperationException iex)
     {
         Notification = new NotificationModel(
             "Failed!",
             "Failed to update Tenant, please provide valide name",
             NotificationModel.NotificationType.Fail);
         _logger.LogError(iex.Message);
     }
     catch (Exception ex)
     {
         Notification = new NotificationModel(
             "Failed!!",
             "Failed to update Tenant , please try again with valid details",
             NotificationModel.NotificationType.Fail);
         _logger.LogError(ex.Message);
     }
 }