Ejemplo n.º 1
0
        public async Task AddOwnerTenantAsync(OwnerTenantDto owner)
        {
            var entry = owner.ToEntry();
            await _baseInfoContext.OwnerTenants.AddAsync(entry);

            await _baseInfoContext.SaveChangesAsync();

            owner.OwnerTenantId = entry.OwnerTenantId;
        }
Ejemplo n.º 2
0
        public void OwnertenatDto_Map_To_Entry()
        {
            DateTime       now   = DateTime.Now;
            OwnerTenantDto otdto = new OwnerTenantDto {
                PersonId        = 1, From = now, IsOwner = false, OccupantCount = 4
                , OwnerTenantId = 7, ApartmentId = 4
            };
            OwnerTenant ow = otdto.ToEntry();

            bool check = false;

            if (ow.IsOwner == otdto.IsOwner && ow.From == otdto.From && ow.ApartmentId == otdto.ApartmentId &&
                ow.OccupantCount == otdto.OccupantCount && ow.PersonId == otdto.PersonId)
            {
                check = true;
            }
            Assert.IsTrue(check);
        }
Ejemplo n.º 3
0
        public async Task EditOwnerTenantAsync(OwnerTenantDto owner)
        {
            var ownertenant = await _baseInfoContext.OwnerTenants.AsNoTracking().FirstOrDefaultAsync(b => b.OwnerTenantId == owner.OwnerTenantId);

            if (ownertenant == null)
            {
                throw new NullReferenceException($"Cannot Find OwnerTenant with {owner.OwnerTenantId} id");
            }
            var entry = owner.ToEntry();

            entry.PersonId    = ownertenant.PersonId;
            entry.ApartmentId = ownertenant.ApartmentId;
            _baseInfoContext.OwnerTenants.Update(entry);
            try
            {
                await _baseInfoContext.SaveChangesAsync();
            }
            catch (Exception e)
            {
            }
        }