Exemplo n.º 1
0
        //public Property StatusUpdate(Property property, RentalStatus status) // for further review, needs to be re-tested
        //{
        //    property.Status = status;
        //    property.Modified = DateTime.Now;

        //    return property;
        //}

        public Property StatusUpdate(RentalStatus status)
        {
            Status   = status;
            Modified = DateTime.Now;

            return(this);
        }
Exemplo n.º 2
0
        private async Task HandleAsync(LeaseFinalizedEvent @event)
        {
            // Handle lease finalize event - update property status
            //
            var rentalProperty = _context.Property.FirstOrDefault(p => p.Id == @event.RentalPropertyId);

            if (rentalProperty != null)
            {
                RentalStatus status = (RentalStatus)Enum.Parse(typeof(RentalStatus), "rented", true);

                rentalProperty.StatusUpdate(status);

                try
                {
                    await _context.SaveChangesAsync();

                    Log.Information("Message  {MessageType} with Id {MessageId} has been handled successfully", @event.MessageType, @event.MessageId);
                }
                catch (Exception ex)
                {
                    //throw ex;
                    Log.Error(ex, "Error while handling {MessageType} message with id {MessageId}.", @event.MessageType, @event.MessageId);
                }
            }



            //throw new NotImplementedException();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Domain behaviours - methods/operations
        /// </summary>

        #region Domain behaviours - methods/operations

        public Property Update(  // Note, rental status is NOT updated manually, but based on other services
            Property property,
            string propertyName,
            string propertyDesc,
            PropertyType propertyType,
            int propertyBuildYear,
            bool isActive,
            bool isShared,
            RentalStatus rentalStatus,
            bool isBasementSuite,
            DateTime updateDate,
            PropertyAddress propertyAddress,
            PropertyFacility propertyFacility,
            PropertyFeature propertyFeature
            )
        {
            property.PropertyName      = propertyName;
            property.PropertyDesc      = propertyDesc;
            property.Type              = propertyType;
            property.PropertyBuildYear = propertyBuildYear;
            property.IsActive          = isActive;
            property.IsShared          = isShared;
            property.IsBasementSuite   = isBasementSuite;
            property.Modified          = updateDate;
            property.Address           = propertyAddress;
            property.Facility          = propertyFacility;
            property.Feature           = propertyFeature;

            return(property);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor - for creating new instance with all required parameters (enforced)
        /// </summary>
        ///
        public CreatePropertyCommand(
            //int propertyId,
            string propertyName,
            string propertyDesc,
            PropertyType propertyType,
            //int? strataCouncilId,
            //int propertyAddressId,
            //int propertyFeatureId,
            //int propertyFacilityId,
            //int? propertyOwnerId,
            //int? propertyManagerId,
            //string propertyLogoImgUrl,
            //string propertyVideoUrl,
            int propertyBuildYear,
            //int propertyMgmntlStatusId,
            bool isActive,
            bool isShared,
            //int? furnishingId,
            RentalStatus rentalStatus,
            bool isBasementSuite,
            DateTime createdDate,
            DateTime updateDate,
            PropertyAddress propertyAddress,
            PropertyFacility propertyFacility,
            PropertyFeature propertyFeature//,

            //int propertyTypeId, //PropertyType propertyType,
            //int rentalStatusId
            )
        {
            //PropertyId = propertyId;
            PropertyName = propertyName;
            PropertyDesc = propertyDesc;
            Type         = propertyType;
            //StrataCouncilId = strataCouncilId;
            //PropertyAddressId = propertyAddressId;
            //PropertyFeatureId = propertyFeatureId;
            //PropertyFacilityId = propertyFacilityId;
            //PropertyOwnerId = propertyOwnerId;
            //PropertyManagerId = propertyManagerId;
            //PropertyLogoImgUrl = propertyLogoImgUrl;
            //PropertyVideoUrl = propertyVideoUrl;
            PropertyBuildYear = propertyBuildYear;
            //PropertyMgmntlStatusId = propertyMgmntlStatusId;
            IsActive = isActive;
            IsShared = isShared;
            //FurnishingId = furnishingId;
            Status           = rentalStatus;
            IsBasementSuite  = isBasementSuite;
            CreatedDate      = createdDate;
            UpdateDate       = updateDate;
            PropertyAddress  = propertyAddress;
            PropertyFacility = propertyFacility;
            PropertyFeature  = propertyFeature;

            //PropertyTypeId = propertyTypeId; //PropertyType = propertyType;
            //RentalStatusId = rentalStatusId;//RentalStatus = rentalStatus;
        }
Exemplo n.º 5
0
        public Rental(RentalStatus status, Guid setId, Guid userId, DateTime rentalDate)
        {
            Id = Guid.NewGuid();

            Status     = status;
            SetId      = setId;
            UserId     = userId;
            RentalDate = rentalDate;
        }
Exemplo n.º 6
0
        // constructor for new rental
        // add initial instance in separate action
        public Rental(int id, Locker locker, Renter renter)
        {
            this.locker = locker;
            this.renter = renter;

            Id             = id;
            StartDate      = DateTime.Now.Date;
            RentalDateTime = DateTime.Now;
            Status         = RentalStatus.Active;
        }
Exemplo n.º 7
0
 protected RentalDto(
     Guid id,
     string name,
     Guid userId,
     RentalStatus rentalStatus)
 {
     Id           = id;
     Name         = name;
     UserId       = userId;
     RentalStatus = rentalStatus;
 }
Exemplo n.º 8
0
        // constructor for existing rental
        public Rental(int id, Locker locker, Renter renter, DateTime startDate, DateTime rentalDateTime, RentalStatus status, List <Instance> instances)
        {
            this.locker    = locker;
            this.renter    = renter;
            this.instances = instances;

            Id             = id;
            StartDate      = startDate;
            RentalDateTime = rentalDateTime;
            Status         = status;
        }
Exemplo n.º 9
0
 internal Rental(
     Guid id,
     string name,
     Guid userId,
     RentalStatus rentalStatus)
     : base(id)
 {
     UserId       = userId;
     Name         = name;
     RentalStatus = rentalStatus;
     RentalItems  = new List <RentalItem>();
 }
Exemplo n.º 10
0
 private FullRentalDto(
     Guid id,
     string name,
     Guid userId,
     RentalStatus rentalStatus,
     IEnumerable <RentalItemDto> rentalItemDto)
     : base(id,
            name,
            userId,
            rentalStatus)
 {
     RentalItemDto = rentalItemDto;
 }
Exemplo n.º 11
0
        private async Task HandleAsync(RentalPropertyStatusChangeEvent e)
        {
            var property = _context.Property
                           .FirstOrDefault(p => p.Id == e.OriginalPropertyId);

            string newStatus = "";

            if (e.CurrentStatus == "Listed")
            {
                newStatus = "Vacant";
            }
            else
            {
                newStatus = e.CurrentStatus;
            }

            //if (e.CurrentStatus == "NotSet")
            //{
            //    newStatus = "UnSet";
            //}


            RentalStatus status = (RentalStatus)Enum.Parse(typeof(RentalStatus), newStatus, true);

            //property.StatusUpdate(property, status); // update method chagned

            if (property != null)
            {
                property.StatusUpdate(status);

                try
                {
                    await _context.SaveChangesAsync();

                    Log.Information("Message  {MessageType} with Id {MessageId} has been handled successfully: Updated property status!", e.MessageType, e.MessageId);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Error while publishing {MessageType} message with id {MessageId}. Property status not updated!d", e.MessageType, e.MessageId);
                    throw ex;
                }
            }



            //var owner = _context.PropertyOwner.FirstOrDefault(p => p.Id == 1);

            //throw new NotImplementedException();
        }
Exemplo n.º 12
0
 /// <summary>
 /// Constructor meant to be used when loading a rental from the data source.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="carId"></param>
 /// <param name="customerId"></param>
 /// <param name="startDate"></param>
 /// <param name="endDate"></param>
 /// <param name="carInitialKms"></param>
 /// <param name="fee"></param>
 /// <param name="depositFee"></param>
 /// <param name="creditCardNumber"></param>
 /// <param name="status"></param>
 /// <param name="carDamaged"></param>
 /// <param name="carFinalKms"></param>
 /// <param name="extraKmsFee"></param>
 /// <param name="finalTotal"></param>
 public Rental(string id, string carId, string customerId, DateTime startDate, DateTime endDate, int carInitialKms, decimal fee, decimal depositFee,
               int creditCardNumber, RentalStatus status, bool carDamaged, int carFinalKms, decimal extraKmsFee, decimal finalTotal) :
     this(id, status)
 {
     // id
     this.carId            = carId;
     this.customerId       = customerId;
     this.startDate        = startDate;
     this.endDate          = endDate;
     this.carInitialKms    = carInitialKms;
     this.fee              = fee;
     this.depositFee       = depositFee;
     this.creditCardNumber = creditCardNumber;
     // status
     this.carDamaged  = carDamaged;
     this.carFinalKms = carFinalKms;
     this.extraKmsFee = extraKmsFee;
     this.finalTotal  = finalTotal;
 }
Exemplo n.º 13
0
        public List <Rental> GetActiveRentals(bool refresh = false)
        {
            if (this.activeRentals.Count == 0 || refresh)
            {
                var rentalsFromFile = File.ReadAllLines(filePath);
                this.activeRentals.Clear();
                foreach (var rentalLine in rentalsFromFile)
                {
                    var          rental = rentalLine.Trim(' ').Split(';');
                    RentalStatus status = (RentalStatus)Enum.Parse(typeof(RentalStatus), rental[9]);

                    if (status == RentalStatus.Ongoing)
                    {
                        this.activeRentals.Add(Rental.Parse(rental));
                    }
                }
            }

            return(this.activeRentals);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Constructor - for creating new instance with all required parameters (enforced)
        /// </summary>
        ///
        public Property(
            string propertyName,
            string propertyDesc,
            PropertyType propertyType,
            string propertyManagerUserName,
            int propertyBuildYear,
            bool isActive,
            bool isShared,
            RentalStatus rentalStatus,
            bool isBasementSuite,
            DateTime createdDate,
            DateTime updateDate,

            //OwnerAddress ownerAddress,

            PropertyAddress propertyAddress,
            PropertyFacility propertyFacility,
            PropertyFeature propertyFeature

            )
        {
            PropertyName            = propertyName;
            PropertyDesc            = propertyDesc;
            Type                    = propertyType;
            PropertyManagerUserName = propertyManagerUserName;
            PropertyBuildYear       = propertyBuildYear;
            IsActive                = isActive;
            IsShared                = isShared;
            Status                  = rentalStatus;
            IsBasementSuite         = isBasementSuite;
            Created                 = createdDate;
            Modified                = updateDate;

            //OAddress = ownerAddress;
            Address  = propertyAddress;
            Facility = propertyFacility;
            Feature  = propertyFeature;
        }
Exemplo n.º 15
0
 public void UpdateStatus(int bookId, RentalStatus status)
 {
     BooksDatabase.Collection[bookId].Status = status;
 }
Exemplo n.º 16
0
 public IQueryable <Rental> FindRentalByRentalStatus(RentalStatus status)
 {
     return(AllRentals().Where(c => status == RentalStatus.Expired ? c.DateOfExpire <DateTime.Today : c.DateOfExpire> DateTime.Today));
 }
Exemplo n.º 17
0
 private Rental(string id = null, RentalStatus status = RentalStatus.Ongoing)
     : base(id)
 {
     this.status = status;
 }