/// <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); }
public static bool UpdateAddress(PropertyAddress address) { SqlAddressProvider sqlAddressProvider = new SqlAddressProvider(); var isUpdate = sqlAddressProvider.UpdateAddress(address); return(isUpdate); }
/// <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; }
public async Task<int> AddressCreate(PropertyAddress address) { try { return await RealEstateDB.SingleAsync<int>("dbo.AddressCreate", address); } catch (Exception ex) { logger.Error(string.Format("Error creating address for customerId:{0})", address.CustomerId, ex)); throw; } }
protected virtual void Prepare() { Property property = DbContext.Properties.FirstOrDefault(x => x.PropertyId == Parameters.PropertyId); Property = new Property(); if (property != null) { Property = property; } PropertyFeatures = new List <PropertyFeature>(); Property.PropertyFeatures = PropertyFeatures; Property.TypeId = (int)Parameters.PropertyType; Property.SellingCondition = (int)Parameters.PropertyStatus; Property.Price = Parameters.Price; Property.PropertyDescription = Parameters.PropertyDescription; Property.AddDate = DateTime.Now; foreach (PhotoModel ph in Parameters.Photos) { Photo photo = new Photo(); photo.PhotoPath = ph.PhotoPath; photo.PhotoSize = ph.PhotoSize; photo.PhotoTitle = ph.PhotoTitle; photo.Extension = ph.Extension; photo.UploadedOn = DateTime.Now; Property.Photos.Add(photo); } PropertyAddress propertyAddress = new PropertyAddress(); if (Property.PropertyAddress != null) { propertyAddress = Property.PropertyAddress; } propertyAddress.CityId = Parameters.City; propertyAddress.DistrictId = Parameters.District; propertyAddress.MetroId = Parameters.Metro; propertyAddress.Description = Parameters.AddressDescription; Property.PropertyAddress = propertyAddress; Property.User = User; }
public static int AddAddress(string city, string street, string block, int apartment) { var address = new PropertyAddress { City = city, Street = street, Block = block, Apartment = apartment }; using (var context = new RepositoryPropertyAddresses()) { return(context.AddAddress(address)); }; }
/// <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; }
public async Task <CreatePropertyCommandResult> Handle(CreatePropertyCommand request, CancellationToken cancellationToken) { #region Create property aggregate root var createdProperty = new CreatePropertyCommandResult(); var address = new PropertyAddress(request.PropertySuiteNumber, request.PropertyNumber, request.PropertyStreet, request.PropertyCity, request.PropertyStateProvince, request.PropertyZipPostCode, request.PropertyCountry); var feature = new PropertyFeature(request.NumberOfBathrooms, request.NumberOfBathrooms, request.NumberOfLayers, request.NumberOfParking, request.BasementAvailable, request.TotalLivingArea, request.IsShared, request.FeatureNotes); var facility = new PropertyFacility(request.Stove, request.Refrigerator, request.Dishwasher, request.AirConditioner, request.Laundry, request.BlindsCurtain, request.Furniture, request.Tvinternet, request.CommonFacility, request.SecuritySystem, request.UtilityIncluded, request.FireAlarmSystem, request.FacilityNotes, request.Others); var property = new Property(request.PropertyName, request.PropertyDesc, request.Type, request.PropertyManagerUserName, request.PropertyBuildYear, true, request.IsShared, request.Status, request.BasementAvailable, DateTime.Now, DateTime.Now, address, facility, feature); await _context.AddAsync(property); #endregion PropertyOwner owner = null; if (request.PropertyOwnerId == 0) { object ownerAddress = null; if (!request.IsSameAddress) { ownerAddress = new OwnerAddress(request.OwnerStreetNumber, request.OwnerCity, request.OwnerStateProv, request.OwnerCountry, request.OwnerZipPostCode); } else { ownerAddress = new OwnerAddress(request.PropertySuiteNumber + " " + request.PropertyNumber + " " + request.PropertyStreet, request.PropertyCity, request.PropertyStateProvince, request.PropertyCountry, request.PropertyZipPostCode); } owner = property.AddOwner("NotSet", request.FirstName, request.LastName, request.ContactEmail, request.ContactTelephone1, request.ContactTelephone2, request.OnlineAccessEnbaled, request.UserAvartaImgUrl, request.IsActive, request.RoleId, request.Notes, (OwnerAddress)ownerAddress); await _context.AddAsync(owner); } else { owner = _context.PropertyOwner.FirstOrDefault(o => o.Id == request.PropertyOwnerId); var ownerProperty = property.AddExsitingOwner(owner); owner.OwnerProperty.Add(ownerProperty); } try { await _context.SaveChangesAsync(); // comment out for testing message sending ONLY int PropertyId = property.Id; int NewOwnerId = owner.Id; request.PropertyId = property.Id; request.CreatedDate = property.Created; request.UpdateDate = property.Modified; //Populate return resultEnum.GetName(typeof()) // createdProperty.Id = PropertyId; createdProperty.PropertyName = request.PropertyName; createdProperty.Type = request.Type.ToString(); createdProperty.Status = request.Status.ToString(); createdProperty.PropertyLogoImgUrl = request.PropertyLogoImgUrl; createdProperty.IsShared = request.IsShared; createdProperty.IsActive = request.IsActive; createdProperty.IsBasementSuite = request.IsBasementSuite; createdProperty.CreatedDate = DateTime.Now.ToString("MMMM dd, yyyy"); createdProperty.UpdateDate = DateTime.Now.ToString("MMMM dd, yyyy"); createdProperty.PropertySuiteNumber = request.PropertySuiteNumber; createdProperty.PropertyStreet = request.PropertyStreet; createdProperty.PropertyCity = request.PropertyCity; createdProperty.PropertyStateProvince = request.PropertyStateProvince; createdProperty.PropertyZipPostCode = request.PropertyZipPostCode; createdProperty.PropertyCountry = request.PropertyCountry; Log.Information("Property with id {PropertyName} has been successfully created.", property.PropertyName); // Publish Domain Event (MediatR pattern) AssetCore.Events.PropertyCreatedEvent domainEvent = new AssetCore.Events.PropertyCreatedEvent(property); await _mediator.Publish(domainEvent); // Publish Integration Event (RabbitMQ) var streetNum = request.PropertySuiteNumber + " " + request.PropertyNumber + " " + request.PropertyStreet; //var streetNum = address.PropertySuiteNumber + " " + address.PropertyNumber + " " + address.PropertyStreet; // Send message to MQ // PropertyCreatedEvent e = new PropertyCreatedEvent(Guid.NewGuid(), request.PropertyId, request.PropertyName, request.PropertyManagerUserName, request.PropertyBuildYear, request.Type.ToString(), request.BasementAvailable, request.IsShared, request.NumberOfBedrooms, request.NumberOfBathrooms, request.NumberOfLayers, request.NumberOfParking, request.TotalLivingArea, streetNum, request.PropertyCity, request.PropertyStateProvince, request.PropertyCountry, request.PropertyZipPostCode, NewOwnerId, request.FirstName, request.LastName, request.ContactEmail, request.ContactTelephone1, request.ContactTelephone2, request.OwnerStreetNumber, request.OwnerCity, request.OwnerStateProv, request.OwnerZipPostCode, request.OwnerCountry); try { await _messagePublisher.PublishMessageAsync(e.MessageType, e, "asset_created"); // publishing the message Log.Information("Message {MessageType} with Id {MessageId} has been published successfully", e.MessageType, e.MessageId); } catch (Exception ex) { Log.Error(ex, "Error while publishing {MessageType} message with id {MessageId}.", e.MessageType, e.MessageId); } // Log message for reconciliation purpose ******** This part can be replaced by Serilog *************** // var msgDetails = new MessageDetails(); msgDetails.PrincicipalId = e.PropertyId; msgDetails.PrincipalType = "Property"; msgDetails.PrincipalNameDesc = e.PropertyName; msgDetails.OperationType = "Create"; var details = msgDetails.ToBsonDocument(); var msg = new Message(e.MessageId, "Asset Management", details, "asset_created", "asset_created.*", "Publish", DateTime.Now); await _loggingService.LogMessage(msg); } catch (Exception ex) { //throw ex; Log.Error(ex, "Error while creating property, {PropertyName} has not been created.", request.PropertyName); } return(createdProperty); //return new CreatePropertyCommandResult() { }; }
public void Add(Property property, PropertyAddress propertyAddress, PropertyFacility propertyFacility, PropertyFeature propertyFeature) { _propertyService.AddProperty(property, propertyAddress, propertyFacility, propertyFeature); }
public void AddProperty(Property property, PropertyAddress propertyAddress, PropertyFacility propertyFacility, PropertyFeature propertyFeature) { _propertyRepository.Add(property, propertyAddress, propertyFacility, propertyFeature); }
async private void submitLead(object o) { #region Process Customer if (!IsExistingCustomer) { if ((ErrorMessage = await new ServiceLayer().AddCustomer(Customer.toDTO())) != null) { return; } Customer = new Customer(ServiceLayer.Customer); PropertyAddress.CustomerID = Customer.CustomerID; } else // If Customer does exist. { PropertyAddress.CustomerID = Customer.CustomerID; if ((ErrorMessage = await new ServiceLayer().UpdateCustomer(Customer.toDTO())) != null) { return; } } #endregion #region Process Address if (PropertyAddress.AddressID == 0) { if ((ErrorMessage = await new ServiceLayer().AddAddress(PropertyAddress.toDTO())) != null) { return; } PropertyAddress.AddressID = ServiceLayer.Address.AddressID; } else // If ProeprtyAddress does exist. { if ((ErrorMessage = await new ServiceLayer().UpdateAddress(PropertyAddress.toDTO())) != null) { return; } } #endregion #region Process Lead if (Lead.LeadTypeID == 1) { // If KnockerResponse does not exist if (KnockerResponse.KnockerResponseID == 0) { if ((ErrorMessage = await new ServiceLayer().AddKnockerResponse(KnockerResponse.toDTO())) != null) { return; } KnockerResponse = new KnockerResponse(ServiceLayer.KnockerResponse); Lead.KnockerResponseID = KnockerResponse.KnockerResponseID; Lead.CreditToID = KnockerResponse.KnockerID; } else { /// If KnockerRepsonse does exist? /// Perhaps add checkbox to signal create window to select knocker response from table? /// In which case this becomes a KnockerResponseUpdate area. } } else if (Lead.LeadTypeID == 2) { if (Referrer.ReferrerID == 0) { if ((ErrorMessage = await new ServiceLayer().AddReferrer(Referrer.toDTO())) != null) { return; } Referrer = new Referrer(ServiceLayer.Referrer); Lead.CreditToID = Referrer.ReferrerID; } else { /// If Referrer does exist? /// Perhaps add checkbox to signal create window to select Referrer from table? /// In which case this becomes a ReferrerUpdate area. } } Lead.SalespersonID = LoggedInEmployee.EmployeeID; Lead.CustomerID = Customer.CustomerID; Lead.AddressID = PropertyAddress.AddressID; Lead.Status = "A"; if (Lead.LeadID == 0) { if ((ErrorMessage = await new ServiceLayer().AddLead(Lead.toDTO())) != null) { return; } Lead.LeadID = ServiceLayer.Lead.LeadID; } else { if ((ErrorMessage = await new ServiceLayer().UpdateLead(Lead.toDTO())) != null) { return; } } OnRequestClose(this, new EventArgs()); #endregion }
public async Task <UpdatePropertyCommandResult> Handle(UpdatePropertyCommand request, CancellationToken cancellationToken) { var ppt = _context.Property.Include(op => op.OwnerProperty).ThenInclude(o => o.PropertyOwner).FirstOrDefault(p => p.Id == request.PropertyId); // var address = new PropertyAddress(request.PropertySuiteNumber, request.PropertyNumber, request.PropertyStreet, request.PropertyCity, request.PropertyStateProvince, request.PropertyZipPostCode, request.PropertyCountry); var feature = new PropertyFeature(request.NumberOfBedrooms, request.NumberOfBathrooms, request.NumberOfLayers, request.NumberOfParking, request.BasementAvailable, request.TotalLivingArea, request.IsShared, request.FeatureNotes); var facility = new PropertyFacility(request.Stove, request.Refrigerator, request.Dishwasher, request.AirConditioner, request.Laundry, request.BlindsCurtain, request.Furniture, request.Tvinternet, request.CommonFacility, request.SecuritySystem, request.UtilityIncluded, request.FireAlarmSystem, request.Others, request.FacilityNotes); var updated = ppt.Update(ppt, request.PropertyName, request.PropertyDesc, request.PropertyType1, request.PropertyBuildYear, request.IsActive, request.IsShared, request.Status, request.BasementAvailable, DateTime.Now, address, facility, feature); _context.Property.Update(updated); var owners = ppt.OwnerProperty.Select(o => o.PropertyOwner).ToList(); //var owners = _context.PropertyOwner // .Include(op => op.OwnerProperty) // .ThenInclude(p => p.FirstOrDefault().PropertyId == request.PropertyId).ToList(); var contracts = _context.ManagementContract //.Include(p => p.Property) .Where(p => p.PropertyId == request.PropertyId).ToList(); var updatedProperty = new UpdatePropertyCommandResult(); // need to populate it either manual or automapper*************************** updatedProperty.PropertyId = request.PropertyId; updatedProperty.Id = request.PropertyId; updatedProperty.AirConditioner = request.AirConditioner; updatedProperty.BasementAvailable = request.BasementAvailable; updatedProperty.CommonFacility = request.CommonFacility; updatedProperty.Dishwasher = request.Dishwasher; updatedProperty.FacilityNotes = request.FacilityNotes; updatedProperty.FireAlarmSystem = request.FireAlarmSystem; //updatedProperty.FurnishingId = request.FurnishingId; updatedProperty.Furniture = request.Furniture; updatedProperty.IsActive = request.IsActive; updatedProperty.IsShared = request.IsShared; updatedProperty.Laundry = request.Laundry; updatedProperty.NumberOfBathrooms = request.NumberOfBathrooms; updatedProperty.NumberOfBedrooms = request.NumberOfBedrooms; updatedProperty.NumberOfLayers = request.NumberOfLayers; updatedProperty.NumberOfParking = request.NumberOfParking; updatedProperty.Others = request.Others; updatedProperty.PropertyBuildYear = request.PropertyBuildYear; updatedProperty.PropertyCity = request.PropertyCity; updatedProperty.PropertyCountry = request.PropertyCountry; updatedProperty.PropertyDesc = request.PropertyDesc; //updatedProperty.PropertyLogoImgUrl = request.PropertyLogoImgUrl; //updatedProperty.PropertyManagerId = request.PropertyManagerId; updatedProperty.PropertyName = request.PropertyName; updatedProperty.PropertyNumber = request.PropertyNumber; updatedProperty.PropertyStateProvince = request.PropertyStateProvince; updatedProperty.PropertyStreet = request.PropertyStreet; updatedProperty.PropertySuiteNumber = request.PropertySuiteNumber; //updatedProperty.PropertyVideoUrl = request.PropertyVideoUrl; updatedProperty.PropertyZipPostCode = request.PropertyZipPostCode; updatedProperty.Refrigerator = request.Refrigerator; updatedProperty.SecuritySystem = request.SecuritySystem; updatedProperty.FeatureNotes = request.FeatureNotes; updatedProperty.Status = request.Status.ToString(); //*************************************************************** updatedProperty.Stove = request.Stove; updatedProperty.TotalLivingArea = request.TotalLivingArea; updatedProperty.Tvinternet = request.Tvinternet; updatedProperty.PropertyType1 = request.PropertyType1.ToString(); //*************************************************************** updatedProperty.Type = request.PropertyType1.ToString(); // new for client side rendering updatedProperty.UtilityIncluded = request.UtilityIncluded; updatedProperty.CreationDate = ppt.Created.ToString("MMMM dd, yyyy"); updatedProperty.CreatedDate = ppt.Created.ToString("MMMM dd, yyyy"); //new for client side rendering updatedProperty.UpdateDate = updated.Modified.ToString("MMMM dd, yyyy"); updatedProperty.OwnerList = owners; updatedProperty.ContractList = contracts; try { await _context.SaveChangesAsync(); // logging Log.Information("The property {PorpertyName} has been updated successfully", ppt.PropertyName); // Send messages if necessary PropertyUpdateEvent e = new PropertyUpdateEvent(Guid.NewGuid(), request.PropertyId, request.PropertyName, request.PropertyBuildYear, request.PropertyType1.ToString(), request.BasementAvailable, request.IsShared, request.NumberOfBedrooms, request.NumberOfBathrooms, request.NumberOfLayers, request.NumberOfParking, request.TotalLivingArea, request.PropertyNumber + " " + request.PropertyStreet, request.PropertyCity, request.PropertyStateProvince, request.PropertyCountry, request.PropertyZipPostCode); try { await _messagePublisher.PublishMessageAsync(e.MessageType, e, "asset_created"); // publishing the message } catch (Exception ex) { Log.Error(ex, "Error while publishing {MessageType} message with id {MessageId}.", e.MessageType, e.MessageId); } } catch (Exception ex) { //throw ex; Log.Error(ex, "Error occured while deleting the image for the property {PropertyName}.", ppt.PropertyName); } return(updatedProperty); //.true; }
async public void submitCustomer(object o) { #region Customer if (Customer.CustomerID == 0) // If the Customer doesn't exist (it should exist) { // Create the Customer if ((ErrorMessage = await new ServiceLayer().AddCustomer(Customer.toDTO())) != null) { return; } Customer = new Customer(ServiceLayer.Customer); // Add it to the Customers list Customers.Add(Customer); } else if (Customer.CustomerID > 0) // If the Claim does exist (it should) { // Update the Customer if ((ErrorMessage = await new ServiceLayer().UpdateCustomer(Customer.toDTO())) != null) { return; } // Overwrite the original Customer in the Customers list with the updated information Customer customer = Customers.Where(c => c.CustomerID == Customer.CustomerID).Single(); int index = Customers.IndexOf(customer); Customers[index] = new Customer(ServiceLayer.Customer); Customer = Customers[index]; // Reassign the CustomerName property in any Claims it is attached to in case it changed. //var claims = Claims.Where(c => c.CustomerID == Customer.CustomerID).ToList(); //foreach (var c in claims) //{ // int i = Claims.IndexOf(c); // Claims[i].CustomerName = Customer.FullName; //} } #endregion #region PropertyAddress if (PropertyAddress.AddressID == 0) // If the PropertyAddress does not exist. { // Create the Address if ((ErrorMessage = await new ServiceLayer().AddAddress(PropertyAddress.toDTO())) != null) { return; } PropertyAddress = new Address(ServiceLayer.Address); Addresses.Add(PropertyAddress); } else if (PropertyAddress.AddressID > 0) // If the PropertyAddress does exist (it should) { // Update the PropertyAddress if ((ErrorMessage = await new ServiceLayer().UpdateAddress(PropertyAddress.toDTO())) != null) { return; } // Overwrite the original Address in the Addresses list with the updated information Address address = Addresses.Where(a => a.AddressID == PropertyAddress.AddressID).Single(); int index = Addresses.IndexOf(address); Addresses[index] = new Address(ServiceLayer.Address); } #endregion #region BillingAddress if (!BillingSameAsProperty) // If BillingAddress is NOT the same as PropertyAddress { if (BillingAddress.AddressID == 0) // If the PropertyAddress does not exist. { // Create the Address if ((ErrorMessage = await new ServiceLayer().AddAddress(BillingAddress.toDTO())) != null) { return; } BillingAddress = new Address(ServiceLayer.Address); Addresses.Add(BillingAddress); } else if (BillingAddress.AddressID > 0) // If the PropertyAddress does exist (it should) { // Update the PropertyAddress if ((ErrorMessage = await new ServiceLayer().UpdateAddress(BillingAddress.toDTO())) != null) { return; } // Overwrite the original Address in the Addresses list with the updated information Address address = Addresses.Where(a => a.AddressID == BillingAddress.AddressID).Single(); int index = Addresses.IndexOf(address); Addresses[index] = new Address(ServiceLayer.Address); } } #endregion }