1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System.Linq;
- using UnivateProperties_API.Containers.Timeshare;
- using UnivateProperties_API.Context;
- using UnivateProperties_API.Model.Users;
-
- namespace UnivateProperties_API.Helpers.Communication
- {
- public class EmailCodedFieldsPopulator
- {
- private readonly DataContext _dbContext;
-
- public EmailCodedFieldsPopulator(DataContext dataContext)
- {
- _dbContext = dataContext;
- }
- public EmailCodedFieldsPopulator( )
- {
-
- }
-
- public string getCodedBody(string htmlBody, Person sendTo, TimeshareWeekDto sellItem)
- {
- var agent = _dbContext.Agents.Where(ag => ag.Id == sellItem.AgentId).FirstOrDefault();
- htmlBody = htmlBody.Replace("[ReferedByAgent]", sellItem.ReferedByAgent.ToString());
- htmlBody = htmlBody.Replace("[AgentId]", sellItem.AgentId.ToString());
- htmlBody = htmlBody.Replace("[AgencyId]", sellItem.AgencyId.ToString());
- htmlBody = htmlBody.Replace("[OwnerId]", sellItem.OwnerId.ToString());
- htmlBody = htmlBody.Replace("[AgentAsRep]", sellItem.AgentAsRep.ToString());
- htmlBody = htmlBody.Replace("[OtherResort]", sellItem.OtherResort.ToString());
- htmlBody = htmlBody.Replace("[OtherResortName]", sellItem.OtherResortName != null ? sellItem.OtherResortName.ToString() : "");
- htmlBody = htmlBody.Replace("[ResortCode]", sellItem.ResortCode.ToString());
- htmlBody = htmlBody.Replace("[ResortName]", sellItem.ResortName.ToString());
- htmlBody = htmlBody.Replace("[RegionId]", sellItem.RegionId.ToString());
- htmlBody = htmlBody.Replace("[Season]", sellItem.Season.ToString());
- htmlBody = htmlBody.Replace("[Module]", sellItem.Module.ToString());
- htmlBody = htmlBody.Replace("[Bedrooms]", sellItem.Bedrooms.ToString());
- htmlBody = htmlBody.Replace("[MaxSleep]", sellItem.MaxSleep.ToString());
- htmlBody = htmlBody.Replace("[UnitNumber]", sellItem.UnitNumber.ToString());
- htmlBody = htmlBody.Replace("[WeekNumber]", sellItem.WeekNumber != null ? sellItem.WeekNumber.ToString() : "");
- htmlBody = htmlBody.Replace("[LevyAmount]", sellItem.LevyAmount.ToString());
- htmlBody = htmlBody.Replace("[CurrentYearBanked]", sellItem.CurrentYearBanked.ToString());
- htmlBody = htmlBody.Replace("[BankedWith]", sellItem.BankedWith != null ? sellItem.BankedWith.ToString() : "");
- htmlBody = htmlBody.Replace("[Valid]", sellItem.Valid != null ? sellItem.Valid.ToString() : "");
- htmlBody = htmlBody.Replace("[IsDeleted]", sellItem.IsDeleted.ToString());
- htmlBody = htmlBody.Replace("[Display]", sellItem.Display.ToString());
- htmlBody = htmlBody.Replace("[LeviesPaidInFull]", sellItem.LeviesPaidInFull.ToString());
- htmlBody = htmlBody.Replace("[WeekPlacedForRental]", sellItem.WeekPlacedForRental.ToString());
- htmlBody = htmlBody.Replace("[OriginalPurchaseDate]", sellItem.OriginalPurchaseDate.ToString());
- htmlBody = htmlBody.Replace("[OriginalPurchasePrice]", sellItem.OriginalPurchasePrice.ToString());
- htmlBody = htmlBody.Replace("[ArrivalDate]", sellItem.ArrivalDate.ToString());
- htmlBody = htmlBody.Replace("[DepartureDate]", sellItem.DepartureDate.ToString());
- htmlBody = htmlBody.Replace("[SellPrice]", sellItem.SellPrice.ToString());
- htmlBody = htmlBody.Replace("[AgentCommision]", sellItem.AgentCommision.ToString());
- htmlBody = htmlBody.Replace("[Mandate]", sellItem.Mandate != null ? sellItem.Mandate.ToString() : "");
- htmlBody = htmlBody.Replace("[StatusId]", sellItem.StatusId.ToString());
- htmlBody = htmlBody.Replace("[Status]", sellItem.Status != null ? sellItem.Status.ToString() : "");
- htmlBody = htmlBody.Replace("[Region]", sellItem.Region.ToString());
-
- if (agent != null)
- {
- htmlBody = htmlBody.Replace("[Agent]", agent.FullName != null ? agent.FullName.ToString() : "");
- htmlBody = htmlBody.Replace("[Agency]", agent.Agency != null ? agent.Agency.ToString() : "");
- }
- else
- {
- htmlBody = htmlBody.Replace("[Agent]", "");
- htmlBody = htmlBody.Replace("[Agency]", "");
- htmlBody = htmlBody.Replace("[Owner]", sendTo.FullName != null ? sendTo.FullName.ToString() : "");
- }
-
- htmlBody = htmlBody.Replace("[BidItems]", sellItem.BidItems != null ? sellItem.BidItems.ToString() : "");
- htmlBody = htmlBody.Replace("[ProcessFlows]", sellItem.ProcessFlows != null ? sellItem.ProcessFlows.ToString() : "");
- htmlBody = htmlBody.Replace("[Id]", sellItem.Id.ToString());
- htmlBody = htmlBody.Replace("[Created]", sellItem.Created.ToString());
- htmlBody = htmlBody.Replace("[Modified]", sellItem.Modified.ToString());
- htmlBody = htmlBody.Replace("[ModifiedBy]", sellItem.ModifiedBy != null ? sellItem.ModifiedBy.ToString() : "");
- return htmlBody;
- }
- }
- }
|