public static List <ErrorMessage> ValidateConfirmTransfer( WaterTransferRegistrationDto waterTransferRegistrationDto, WaterTransferDto waterTransferDto, UserDto currentUser) { var result = new List <ErrorMessage>(); if (currentUser.Role.RoleID != (int)RoleEnum.Admin) { if (waterTransferRegistrationDto.WaterTransferTypeID == (int)WaterTransferTypeEnum.Selling && !waterTransferDto.SellerRegistration.Account.Users.Select(x => (int?)x.UserID) .Contains(waterTransferRegistrationDto.UserID)) { result.Add(new ErrorMessage() { Message = "Confirming user does not match seller." }); } if (waterTransferRegistrationDto.WaterTransferTypeID == (int)WaterTransferTypeEnum.Buying && !waterTransferDto.BuyerRegistration.Account.Users.Select(x => (int?)x.UserID) .Contains(waterTransferRegistrationDto.UserID)) { result.Add(new ErrorMessage() { Message = "Confirming user does not match buyer." }); } } return(result); }
public static List <ErrorMessage> ValidateCancelTransfer( WaterTransferRegistrationDto waterTransferRegistrationDto, WaterTransferDto waterTransferDto, UserDto currentUser) { var result = new List <ErrorMessage>(); if (waterTransferDto.BuyerRegistration.IsRegistered || waterTransferDto.SellerRegistration.IsRegistered) { result.Add(new ErrorMessage() { Message = "Cannot cancel transfer because one of the parties has already registered this transfer." }); } if (currentUser.Role.RoleID != (int)RoleEnum.Admin) { if (waterTransferRegistrationDto.WaterTransferTypeID == (int)WaterTransferTypeEnum.Selling && ! waterTransferDto.SellerRegistration.Account.Users.Select(x => (int?)x.UserID) .Contains(waterTransferRegistrationDto.UserID)) { result.Add(new ErrorMessage() { Message = "Canceling user does not match seller." }); } if (waterTransferRegistrationDto.WaterTransferTypeID == (int)WaterTransferTypeEnum.Buying && ! waterTransferDto.BuyerRegistration.Account.Users.Select(x => (int?)x.UserID) .Contains(waterTransferRegistrationDto.UserID)) { result.Add(new ErrorMessage() { Message = "Canceling user does not match buyer." }); } } return(result); }
private static List <MailMessage> GenerateCancelTransferEmail(string rioUrl, WaterTransferDto waterTransfer, SitkaSmtpClientService smtpClient) { var receivingAccount = waterTransfer.BuyerRegistration.Account; var transferringAccount = waterTransfer.SellerRegistration.Account; var mailMessages = new List <MailMessage>(); var stringToReplace = "REPLACE_WITH_ACCOUNT_NUMBER"; var messageBody = $@"This transaction has been canceled, and your annual water allocation will not be updated. <ul> <li><strong>Buyer:</strong> {receivingAccount.AccountName} ({string.Join(", ", receivingAccount.Users.Select(x => x.Email))})</li> <li><strong>Seller:</strong> {transferringAccount.AccountName} ({string.Join(", ", transferringAccount.Users.Select(x => x.Email))})</li> <li><strong>Quantity:</strong> {waterTransfer.AcreFeetTransferred} acre-feet</li> </ul> <a href=""{rioUrl}/landowner-dashboard/{stringToReplace}"">View your Landowner Dashboard</a> to see your current water allocation, which has not been updated to reflect this trade. <br /><br /> {smtpClient.GetDefaultEmailSignature()}"; var mailTos = new List <AccountDto> { receivingAccount, transferringAccount }.SelectMany(x => x.Users); foreach (var mailTo in mailTos) { var specificMessageBody = messageBody.Replace(stringToReplace, (receivingAccount.Users.Contains(mailTo) ? receivingAccount.AccountNumber : transferringAccount.AccountNumber).ToString()); var mailMessage = new MailMessage { Subject = "Water Transfer Canceled", Body = $"Hello {mailTo.FullName},<br /><br />{specificMessageBody}" }; mailMessage.To.Add(new MailAddress(mailTo.Email, mailTo.FullName)); mailMessages.Add(mailMessage); } return(mailMessages); }
private static List <MailMessage> GenerateAcceptedOfferEmail(string rioUrl, OfferDto offer, TradeDto currentTrade, PostingDto posting, WaterTransferDto waterTransfer, SitkaSmtpClientService smtpClient) { AccountDto buyer; AccountDto seller; if (currentTrade.CreateAccount.AccountID == posting.CreateAccount.AccountID) { if (posting.PostingType.PostingTypeID == (int)PostingTypeEnum.OfferToBuy) { buyer = posting.CreateAccount; seller = currentTrade.CreateAccount; } else { buyer = currentTrade.CreateAccount; seller = posting.CreateAccount; } } else { if (posting.PostingType.PostingTypeID == (int)PostingTypeEnum.OfferToBuy) { buyer = posting.CreateAccount; seller = currentTrade.CreateAccount; } else { buyer = currentTrade.CreateAccount; seller = posting.CreateAccount; } } var mailMessages = new List <MailMessage>(); var messageBody = $@"Your offer to trade water has been accepted. <ul> <li><strong>Buyer:</strong> {buyer.AccountName} ({string.Join(", ", buyer.Users.Select(x=>x.Email))})</li> <li><strong>Seller:</strong> {seller.AccountName} ({string.Join(", ", seller.Users.Select(x => x.Email))})</li> <li><strong>Quantity:</strong> {offer.Quantity} acre-feet</li> <li><strong>Unit Price:</strong> {offer.Price:$#,##0.00} per acre-foot</li> <li><strong>Total Price:</strong> {(offer.Price * offer.Quantity):$#,##0.00}</li> </ul> To finalize this transaction, the buyer and seller must complete payment and any other terms of the transaction. Once payment is complete, the trade must be confirmed by both parties within the Water Accounting Platform before the district will recognize the transfer. <br /><br /> <a href=""{rioUrl}/register-transfer/{waterTransfer.WaterTransferID}"">Confirm Transfer</a> {smtpClient.GetDefaultEmailSignature()}"; var mailTos = (new List <AccountDto> { buyer, seller }).SelectMany(x => x.Users); foreach (var mailTo in mailTos) { var mailMessage = new MailMessage { Subject = $"Trade {currentTrade.TradeNumber} Accepted", Body = $"Hello {mailTo.FullName},<br /><br />{messageBody}" }; mailMessage.To.Add(new MailAddress(mailTo.Email, mailTo.FullName)); mailMessages.Add(mailMessage); } return(mailMessages); }
public static List <ErrorMessage> ValidateParcels(List <WaterTransferRegistrationParcelDto> waterTransferParcelDtos, WaterTransferDto waterTransferDto) { var result = new List <ErrorMessage>(); //if(waterTransferParcelDto.WaterTransferTypeID == (int) WaterTransferTypeEnum.Selling && waterTransferParcelDto.ConfirmingUserID != waterTransferDto.TransferringUser.UserID) //{ // result.Add(new ErrorMessage() { Message = "Confirming user does not match transferring user." }); //} //if (waterTransferParcelDto.WaterTransferTypeID == (int) WaterTransferTypeEnum.Buying && waterTransferParcelDto.ConfirmingUserID != waterTransferDto.ReceivingUser.UserID) //{ // result.Add(new ErrorMessage() { Message = "Confirming user does not match receiving user." }); //} return(result); }