public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (ExchangeId != 0L) { hash ^= ExchangeId.GetHashCode(); } if (TokenId.Length != 0) { hash ^= TokenId.GetHashCode(); } if (Quant != 0L) { hash ^= Quant.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (FrozenBalance != 0L) { hash ^= FrozenBalance.GetHashCode(); } if (FrozenDuration != 0L) { hash ^= FrozenDuration.GetHashCode(); } if (Resource != global::Tron.Net.Protocol.ResourceCode.Bandwidth) { hash ^= Resource.GetHashCode(); } if (ReceiverAddress.Length != 0) { hash ^= ReceiverAddress.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (FirstTokenId.Length != 0) { hash ^= FirstTokenId.GetHashCode(); } if (FirstTokenBalance != 0L) { hash ^= FirstTokenBalance.GetHashCode(); } if (SecondTokenId.Length != 0) { hash ^= SecondTokenId.GetHashCode(); } if (SecondTokenBalance != 0L) { hash ^= SecondTokenBalance.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public PropertyOwner AddOwner( string userName, string firstName, string lastName, string contactEmail, string contactTelephone1, string contactTelephone2, bool onlineAccess, string userAvartaImgUrl, bool?isActive, int?roleId, string notes, OwnerAddress address) { var owner = new PropertyOwner(userName, firstName, lastName, contactEmail, contactTelephone1, contactTelephone2, false, userAvartaImgUrl, true, 2, "", address, DateTime.Now, DateTime.Now); var ownerProperty = new OwnerProperty(this, owner); owner.OwnerProperty.Add(ownerProperty); return(owner); }
private async Task HandleAsync(UpdateOwnerEvent @event) { var owner = _context.RentalPropertyOwner.Include(o => o.OwnerAddress).FirstOrDefault(o => o.OriginalId == @event.PropertyOwnerId); if (owner != null) { var oAddress = new OwnerAddress(@event.StreetNumber, @event.City, @event.StateProv, @event.ZipPostCode, @event.Country); var updated = owner.Update(owner, @event.FirstName, @event.LastName, @event.ContactEmail, @event.ContactTelephone1, @event.ContactTelephone2, oAddress); _context.RentalPropertyOwner.Update(updated); try { await _context.SaveChangesAsync(); Log.Information("Message {MessageType} with Id {MessageId} has been handled successfully", @event.MessageType, @event.MessageId); } catch (Exception ex) { //throw; Log.Error(ex, "Error while handling {MessageType} message with id {MessageId}.", @event.MessageType, @event.MessageId); } } else { Log.Information("The owner with Id: {OwnerId} does not exist.", @event.PropertyOwnerId); } //throw new NotImplementedException(); }
private async Task HandleAsync(AddOwnerEvent @event) { var rentalProperty = _context.RentalProperty.Include(a => a.Address).FirstOrDefault(p => p.OriginalId == @event.PropertyId); if (rentalProperty != null) { var address = new OwnerAddress(@event.StreetNumber, @event.City, @event.StateProv, @event.Country, @event.ZipPostCode); var owner = new RentalPropertyOwner(@event.OriginalId, @event.FirstName, @event.LastName, @event.ContactEmail, @event.ContactTelephone1, @event.ContactTelephone2, rentalProperty.Id, address, DateTime.Now, DateTime.Now); _context.Add(owner); try { await _context.SaveChangesAsync(); Log.Information("Owner {Owner} has been added to property {Property} successfully", @event.FirstName + " " + @event.LastName, rentalProperty.PropertyName); } catch (Exception ex) { Log.Error(ex, "Error while addinng owner {Owner} to {Property}.", @event.FirstName + " " + @event.LastName, rentalProperty.PropertyName); throw ex; } } else { Log.Information("The rental property with Id: {PrpertyId} does not exist.", @event.PropertyId); } //throw new NotImplementedException(); }
public async Task CreateOwner(CreateOwnerModel owner) { var address = new OwnerAddress { HouseNumber = owner.HouseNumber, StreetName = owner.StreetName, City = owner.City, County = owner.County, PostCode = owner.PostCode }; var addressEntity = await _addressRepo .GetAddress(owner.HouseNumber, owner.StreetName, owner.City, owner.County, owner.PostCode) .SingleOrDefaultAsync(); if (addressEntity == null) { addressEntity = Mapper.Map <ExampleOwnerAddress>(address); await _addressRepo.Add(addressEntity); } var entity = Mapper.Map <ExampleOwner>(owner); entity.Address = addressEntity; await _ownerRepo.Add(entity); }
public async Task <Result> Handle(UpdateBusinessLegalCommand request, CancellationToken token) { var legalAddress = new LegalAddress(request.Address.Line1, request.Address.Line2, request.Address.Zipcode, request.Address.City, request.Address.Country); var ownerAddress = new OwnerAddress(request.Owner.Address.Line1, request.Owner.Address.Line2, request.Owner.Address.Zipcode, request.Owner.Address.City, request.Owner.Address.Country ); var legal = await _context.Set <BusinessLegal>().SingleAsync(e => e.Id == request.LegalId, token); legal.SetKind(request.Kind); legal.SetValidation(request.Validation); legal.SetName(request.Name); legal.SetEmail(request.Email); legal.SetAddress(legalAddress); legal.SetSiret(request.Siret); legal.SetVatIdentifier(request.VatIdentifier); legal.Owner.SetFirstname(request.Owner.FirstName); legal.Owner.SetLastname(request.Owner.LastName); legal.Owner.SetEmail(request.Owner.Email); legal.Owner.SetBirthDate(request.Owner.BirthDate); legal.Owner.SetNationality(request.Owner.Nationality); legal.Owner.SetCountryOfResidence(request.Owner.CountryOfResidence); legal.Owner.SetAddress(ownerAddress); await _context.SaveChangesAsync(token); if (string.IsNullOrWhiteSpace(legal.User.Identifier)) { var userResult = await _mediatr.Process( new CheckBusinessLegalConfigurationCommand(request.RequestUser) { UserId = legal.UserId }, token); if (!userResult.Succeeded) { return(Failure(userResult)); } } else { var result = await _pspService.UpdateBusinessAsync(legal, token); if (!result.Succeeded) { return(Failure(result)); } } return(Success()); }
private async Task HandleAsync(AddOwnerEvent @event) { var rentalProperty = _context.RentalProperty.FirstOrDefault(p => p.OriginalId == @event.PropertyId); if (rentalProperty != null) { var address = new OwnerAddress(@event.StreetNumber, @event.City, @event.StateProv, @event.Country, @event.ZipPostCode); var owner = new RentalPropertyOwner(@event.OriginalId, @event.FirstName, @event.LastName, @event.ContactEmail, @event.ContactTelephone1, @event.ContactTelephone2, address, rentalProperty.Id, DateTime.Now, DateTime.Now); _context.Add(owner); try { await _context.SaveChangesAsync(); Log.Information("Owner {Owner} has been added to property {Property} successfully", @event.FirstName + " " + @event.LastName, rentalProperty.PropertyName); // Send message so that lease service can consume to queue app_approved // need to make sure the rental property exists in Lease service then send message if it does. //************************************************ // It may not need this because as ApproveApplicaiton Event will send property including owner so that it should be created in Lease service already //************************************************ /* * AddOwnerEvent e = new AddOwnerEvent(new Guid(), @event.PropertyId, @event.UserName, @event.FirstName, @event.LastName, * @event.ContactEmail, @event.ContactTelephone1, @event.ContactTelephone2, @event.OnlineAccessEnbaled, * @event.UserAvartaImgUrl, @event.IsActive, @event.RoleId, @event.Notes, @event.StreetNumber, * @event.City, @event.StateProv, @event.ZipPostCode, @event.Country); * * * 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); * } * */ } catch (Exception ex) { Log.Error(ex, "Error while addinng owner {Owner} to {Property}.", @event.FirstName + " " + @event.LastName, rentalProperty.PropertyName); throw ex; } } //throw new NotImplementedException(); }
public PropertyOwner UpdateOwner(PropertyOwner owner, string firstName, string lastName, string email, string telephone1, string telephone2, string avatarUrl, bool isActive, string notes, string streetNumber, string city, string stateProv, string country, string postZipCode) { OwnerAddress updatedAddress = new OwnerAddress( streetNumber, city, stateProv, country, postZipCode ); owner.Update(firstName, lastName, email, telephone1, telephone2, avatarUrl, isActive, notes, updatedAddress); return(owner); }
public RentalPropertyOwner(string firstName, string lastName, string contactEmail, string contactTelephone, string contactOther, OwnerAddress ownerAddress, DateTime create, DateTime updated) { FirstName = firstName; LastName = lastName; ContactEmail = contactEmail; ContactTelephone = contactTelephone; ContactOther = contactOther; OwnerAddress = ownerAddress; Created = create; Modified = updated; }
private async Task DisplayContract(string contractaddress) { DataRow dr = dt.NewRow(); if (!isDecommision(contractaddress)) { var url = "http://127.0.0.1:7545"; string eth_address1 = "0x594559a12AF7CC1085f65c53f4252535Bad12203"; var privateKey1 = "db9820f8b4585f5f022b03e062431636dc965aff525b195cee787c1fe55fd02b"; var account = new Account(privateKey1); var web3 = new Web3(account, url); var iot4 = new OwnerAddress(); var balanceHandler4 = web3.Eth.GetContractQueryHandler <OwnerAddress>(); var balance4 = await balanceHandler4.QueryAsync <String>(contractaddress, iot4); var iot = new ProductName(); var balanceHandler = web3.Eth.GetContractQueryHandler <ProductName>(); var balance = await balanceHandler.QueryAsync <String>(contractaddress, iot); var iot2 = new Description(); var balanceHandler2 = web3.Eth.GetContractQueryHandler <Description>(); var balance2 = await balanceHandler2.QueryAsync <String>(contractaddress, iot2); var iot3 = new SerialNumber(); var balanceHandler3 = web3.Eth.GetContractQueryHandler <SerialNumber>(); var balance3 = await balanceHandler3.QueryAsync <String>(contractaddress, iot3); string[] s = File.ReadAllLines(@"C:\Users\C.z\source\repos\BlockChain Project\BlockChain Project\DecommisionContract.txt"); int a = 0; foreach (string s1 in s) { if (s1 == contractaddress) { a = 1; } } if (a != 1) { dr[0] = contractaddress; dr[1] = balance4; dr[2] = balance; dr[3] = balance2; dr[4] = balance3; dr[5] = balance3; } } dt.Rows.Add(dr); dataGridView1.DataSource = dt; }
public RentalPropertyOwner(int originalId, string firstName, string lastName, string contactEmail, string contactTelephone, string contactOther, OwnerAddress ownerAddress, int rentalPropertyId, DateTime create, DateTime updated) { OriginalId = originalId; FirstName = firstName; LastName = lastName; ContactEmail = contactEmail; ContactTelephone = contactTelephone; ContactOther = contactOther; OwnerAddress = ownerAddress; RentalPropertyId = rentalPropertyId; Created = create; Modified = updated; }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } hash ^= Parameters.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("o="); sb.Append($"{Username} "); sb.Append($"{SessionId} "); sb.Append($"{SessionVersion} "); sb.Append($"{NetworkType} "); sb.Append($"{AddressType} "); sb.Append($"{OwnerAddress.ToString()}"); sb.AppendLine(); return(sb.ToString()); }
//********************************* // Entity Behavors //********************************* public void Update(/*PropertyOwner owner,*/ string firstName, string lastName, string email, string telephone1, string telephone2, string avatarUrl, bool isActive, string notes, OwnerAddress address) { FirstName = firstName; LastName = lastName; ContactEmail = email; ContactTelephone1 = telephone1; ContactTelephone2 = telephone2; UserAvartaImgUrl = avatarUrl; IsActive = isActive; Notes = notes; Address = address; Modified = DateTime.Now; //return owner; }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (Brokerage != 0) { hash ^= Brokerage.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (StorageBytes != 0L) { hash ^= StorageBytes.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (UpdateUrl.Length != 0) { hash ^= UpdateUrl.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static OwnerAddress GetAddressById(int AddressId) { OwnerAddress ownerAddress = new OwnerAddress(); var Data = OwnerService.GetOwnerAddressById(AddressId); if (Data != null) { ownerAddress.Id = Data.Id; ownerAddress.Street1 = Data.Street1; ownerAddress.Street2 = Data.Street2; ownerAddress.City = Data.City; ownerAddress.PostCode = Data.PostCode; ownerAddress.StateId = Data.StateId; } return(ownerAddress); }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (ProposalId != 0L) { hash ^= ProposalId.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } hash ^= votes_.GetHashCode(); if (Support != false) { hash ^= Support.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public PropertyOwner( string userName, string firstName, string lastName, string contactEmail, string contactTelephone1, string contactTelephone2, bool onlineAccess, string userAvartaImgUrl, bool isActive, int roleId, string notes, //string streetNumber, //string city, //string stateProv, //string zipPostCode, //string country, OwnerAddress address, DateTime createdOn, DateTime updatedOn //ICollection<OwnerProperty> ownerProperty ) { UserName = userName; FirstName = firstName; LastName = lastName; ContactEmail = contactEmail; ContactTelephone1 = contactTelephone1; ContactTelephone2 = contactTelephone2; OnlineAccess = onlineAccess; UserAvartaImgUrl = userAvartaImgUrl; IsActive = isActive; RoleId = roleId; Notes = notes; Address = address; Created = createdOn; Modified = updatedOn; //OwnerProperty = ownerProperty; }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (AccountAddress.Length != 0) { hash ^= AccountAddress.GetHashCode(); } if (Type != global::Tron.Net.Protocol.AccountType.Normal) { hash ^= Type.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (ToAddress.Length != 0) { hash ^= ToAddress.GetHashCode(); } if (Amount != 0L) { hash ^= Amount.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (OwnerAddress.Length != 0) { hash ^= OwnerAddress.GetHashCode(); } if (owner_ != null) { hash ^= Owner.GetHashCode(); } if (witness_ != null) { hash ^= Witness.GetHashCode(); } hash ^= actives_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
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() { }; }
private async Task HandleAsync(RentalAppApprovedEvent @event) { var newTenant = new NewTenant(@event.UserName, @event.FirstName, @event.LastName, @event.ContactEmail, @event.ContactTelephone1, @event.ContactTelephone2, @event.ContactOthers, DateTime.Now, DateTime.Now); _context.Add(newTenant); //try //{ // await _context.SaveChangesAsync(); //} //catch (Exception ex) //{ // throw ex; //} var rentalproperty = _context.RentalProperty.Include(a => a.Address).FirstOrDefault(a => a.OriginalId == @event.PropertyId); // Get related rental property //Note above: @event.ProeprtyId comes from the event and is the Id for rental property (in Marketing), it should be named OriginalId in RentalProperty in Lease service if (rentalproperty == null) { var address = new Address(@event.StreetNum, @event.City, @event.StateProvince, @event.Country, @event.ZipPostCode); var owners = new List <RentalPropertyOwner>(); foreach (var owner in @event.PropertyOwners) { var ownerAddress = new OwnerAddress(owner.OwnerStreetNum, owner.OwnerCity, owner.OwnerStateProvinc, owner.OwnerZipPostCode, owner.OwnerCountry); var pOwner = new RentalPropertyOwner(owner.PropertyOwnerId, owner.FirstName, owner.LastName, owner.ContactEmail, owner.ContactTelephone, owner.ContactOther, owner.RentalPropertyId, ownerAddress, DateTime.Now, DateTime.Now); owners.Add(pOwner); } //(IList<RentalPropertyOwner>)@event.PropertyOwners var newRentalProperty = new RentalProperty(@event.PropertyId, DateTime.Now, DateTime.Now, @event.ListingId, /*0,*/ @event.PropertyName, @event.Type, @event.PropertyBuildYear, @event.IsShared, "Pending", @event.IsBasementSuite, @event.NumberOfBedrooms, @event.NumberOfBathrooms, @event.NumberOfLayers, @event.NumberOfParking, @event.TotalLivingArea, @event.Notes, @event.PropertyManagerUserName, address, owners); _context.RentalProperty.Add(newRentalProperty); //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); //} } 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(); }
private async Task HandleAsync(PropertyCreatedEvent @event) { //var p = _context.RentalProperty.FirstOrDefault(r => r.Id == 2); // Test code var ownerAddress = new OwnerAddress(@event.OwnerStreetNum, @event.OwnerCity, @event.OwnerStateProvince, @event.OwnerCountry, @event.OwnerZipPostCode); var owner = new RentalPropertyOwner(@event.OwnerId, @event.OwnerFirstName, @event.OwnerLastName, @event.OwnerContactEmail, @event.OwnerContactTel, @event.OwnerContactOther, ownerAddress, DateTime.Now, DateTime.Now); var owners = new List <RentalPropertyOwner>(); owners.Add(owner); await _context.AddAsync(owner); var address = new Address( @event.StreetNum, @event.City, @event.StateProvince, @event.Country, @event.ZipPostCode); int geoId = 0; geoId = getGeoId(@event.City); var property = new RentalProperty( @event.PropertyId, @event.PropertyName, @event.Type, @event.PropertyManagerUserName, @event.PropertyBuildYear, @event.IsShared, @event.IsBasementSuite, @event.NumberOfBedrooms, @event.NumberOfBathrooms, @event.NumberOfLayers, @event.NumberOfParking, @event.TotalLivingArea, "", DateTime.Now, DateTime.Now, address, geoId, owners); await _context.AddAsync(property); try { await _context.SaveChangesAsync(); Log.Information("Message {MessageType} with Id {MessageId} has been handled successfully", @event.MessageType, @event.MessageId); } catch (Exception ex) { //throw ex; //string messageId = messageObject.Property("MessageId") != null ? messageObject.Property("MessageId").Value<string>() : "[unknown]"; Log.Error(ex, "Error while handling {MessageType} message with id {MessageId}.", @event.MessageType, @event.MessageId); } //throw new NotImplementedException(); //Log.Information("Message {MessageType} with Id {MessageId} has been handled successfully", @event.MessageType, @event.MessageId); //var msgDetails = new MessageDetails(); //msgDetails.PrincicipalId = @event.PropertyId; //msgDetails.PrincipalType = "Property"; //msgDetails.PrincipalNameDesc = @event.PropertyName; //msgDetails.OperationType = "Create"; //var details = msgDetails.ToBsonDocument(); //var msg = new Message(@event.MessageId, "Asset Management", details, "asset_created", "asset_created.*", "Subscription", DateTime.Now); //var messageLoggingService = new MessageLoggingService(); //await messageLoggingService.LogMessage(msg); }
public async Task <AddOwnerToExistingPropertyCommandResult> Handle(AddOwnerToExistingPropertyCommand request, CancellationToken cancellationToken) { var property = _context.Property.FirstOrDefault(p => p.Id == request.PropertyId); PropertyOwner owner = null; var addedOwner = new AddOwnerToExistingPropertyCommandResult(); // Check if the email already exist if adding new owner instead of existing owner // //var user = _context.PropertyOwner.FirstOrDefault(e => e.ContactEmail == request.ContactEmail); //if (user != null) //{ // return new AddOwnerToExistingPropertyCommandResult() { Notes = "The email already exists!"}; //} // populate the addedOnwer addedOwner.UserAvartaImgUrl = request.UserAvartaImgUrl; addedOwner.FirstName = request.FirstName; addedOwner.LastName = request.LastName; addedOwner.UserName = request.UserName; addedOwner.ContactEmail = request.ContactEmail; addedOwner.ContactTelephone1 = request.ContactTelephone1; addedOwner.ContactTelephone2 = request.ContactTelephone2; addedOwner.OnlineAccessEnbaled = request.OnlineAccessEnbaled; addedOwner.IsActive = request.IsActive; addedOwner.RoleId = request.RoleId; addedOwner.Notes = request.Notes; addedOwner.StreetNumber = request.StreetNumber; addedOwner.City = request.City; addedOwner.StateProv = request.StateProv; addedOwner.ZipPostCode = request.ZipPostCode; addedOwner.Country = request.Country; addedOwner.Created = DateTime.Now.ToString("MMMM dd, yyyy"); addedOwner.Updated = DateTime.Now.ToString("MMMM dd, yyyy"); if (request.PropertyOwnerId == 0) { // Check if the email already exist if adding new owner instead of existing owner // var user = _context.PropertyOwner.FirstOrDefault(e => e.ContactEmail == request.ContactEmail); if (user != null) { return(new AddOwnerToExistingPropertyCommandResult() { Notes = "The email already exists!" }); } var ownerAddress = new OwnerAddress(request.StreetNumber, request.City, request.StateProv, request.Country, request.ZipPostCode); owner = property.AddNewOwnerToProperty(request.PropertyId, request.UserName, request.FirstName, request.LastName, request.ContactEmail, request.ContactTelephone1, request.ContactTelephone2, false, request.UserAvartaImgUrl, request.IsActive, 2, request.Notes, ownerAddress); _context.Add(owner); } else { owner = _context.PropertyOwner.Include(a => a.Address).FirstOrDefault(o => o.Id == request.PropertyOwnerId); var ownerProperty = property.AddExistingOwnerToProperty(owner, request.PropertyId); _context.Add(ownerProperty); } try { await _context.SaveChangesAsync(); addedOwner.Id = owner.Id; // logging Log.Information("The new owner {OwnerName} has been added to the property {PorpertyName} successfully", request.FirstName + " " + request.LastName, property.PropertyName); // Send messages if necessary // Publish message to MQ for other service to consume AddOwnerEvent e = new AddOwnerEvent(new Guid(), owner.Id, request.PropertyId, owner.UserName, owner.FirstName, owner.LastName, owner.ContactEmail, owner.ContactTelephone1, owner.ContactTelephone2, owner.OnlineAccess, owner.UserAvartaImgUrl, owner.IsActive, owner.RoleId, owner.Notes, owner.Address.StreetNumber, owner.Address.City, owner.Address.StateProvince, owner.Address.ZipPostCode, owner.Address.Country); 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); } } catch (Exception ex) { //throw ex; Log.Error(ex, "Error occured while adding the new owner {OwnerName} to the property {PropertyName}.", request.FirstName + " " + request.LastName, property.PropertyName); } return(addedOwner); }