Example #1
0
        public Guid AddNewProperty(Guid userId, PropertyAddBasicDto dto)
        {
            var property = new Property()
            {
                LandlordId = userId,
                Beds = dto.Beds,
                StartDate = dto.StartTime,
                Deposit = dto.Deposit,
                Rent = dto.Rent,
                AddressId = dto.AddressId ?? dto.AddressId.Value
            };

            _entities.Properties.Add(property);
            _entities.SaveChanges();

            return property.PropertyId;
        }
Example #2
0
        public Guid EditProperty(Guid userId, PropertyAddBasicDto dto)
        {
            var property = _entities.Properties
                .Where(w => w.PropertyId == dto.PropertyId.Value)
                .SingleOrDefault();

            if (property != null)
            {
                property.PropertyId = dto.PropertyId.Value;
                property.Rent = dto.Rent;
                property.StartDate = dto.StartTime;
                property.Deposit = dto.Deposit;
                property.Beds = dto.Beds;
                property.AddressId = dto.AddressId.Value;
            }

            _entities.SaveChanges();

            return property.PropertyId;
        }