예제 #1
0
        /// <summary>Convert from PaymentMain entity to DTO w/o checking entity state or entity navigation</summary>
        /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param>
        /// <returns>Resultant PaymentMain DTO</returns>
        public PaymentMainDto ToDto(PaymentMainDto dto = null)
        {
            dto       = dto ?? new PaymentMainDto();
            dto.IsNew = false;

            dto.AgentId                = AgentId;
            dto.BankAccountNumber      = BankAccountNumber;
            dto.BankAccountTypeCode    = BankAccountTypeCode;
            dto.CreateDateTime         = CreateDateTime;
            dto.CreateUserId           = CreateUserId;
            dto.EmployerId             = EmployerId;
            dto.IsAgent                = IsAgent;
            dto.PaymentAmount          = PaymentAmount;
            dto.PaymentMainId          = PaymentMainId;
            dto.PaymentMethodCode      = PaymentMethodCode;
            dto.PaymentStatusCode      = PaymentStatusCode;
            dto.PaymentStatusDate      = PaymentStatusDate;
            dto.PaymentSubmittedDate   = PaymentSubmittedDate;
            dto.PaymentTransactionDate = PaymentTransactionDate;
            dto.RoutingTransitNumber   = RoutingTransitNumber;
            dto.UpdateDateTime         = UpdateDateTime;
            dto.UpdateNumber           = UpdateNumber;
            dto.UpdateProcess          = UpdateProcess;
            dto.UpdateUserId           = UpdateUserId;

            return(dto);
        }
예제 #2
0
 public MakePaymentViewModel()
 {
     PaymentMainDto                = new PaymentMainDto();
     PaymentProfileDto             = new PaymentProfileDto();
     EmployerAccountTransactionDto = new EmployerAccountTransactionDto();
     EmployerDto = new EmployerDto();
 }
예제 #3
0
        /// <summary>Convert from PaymentMain DTO to entity</summary>
        /// <param name="dbContext">DB Context to use for attaching entity</param>
        /// <param name="dto">DTO to convert from</param>
        /// <param name="dtoEntities">Used internally to track which dtos have been converted to entites already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant PaymentMain entity</returns>
        public static PaymentMain FromDto(FACTS.Framework.DAL.DbContext dbContext, PaymentMainDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((PaymentMain)dtoEntities[dto]);
            }

            PaymentMain entity = new PaymentMain();

            dtoEntities.Add(dto, entity);
            FromDtoSet(dbContext, dto, entity, dtoEntities);

            if (dbContext != null)
            {
                dbContext.Entry(entity).State = (dto.IsNew ? EntityState.Added : (dto.IsDeleted ? EntityState.Deleted : EntityState.Modified));
            }

            return(entity);
        }
예제 #4
0
        /// <summary>Convert from PaymentMain DTO to entity</summary>
        /// <param name="dbContext">DB Context to use for attaching entity</param>
        /// <param name="dto">DTO to convert from</param>
        /// <param name="dtoEntities">Used internally to track which dtos have been converted to entites already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant PaymentMain entity</returns>
        public static PaymentMain FromDto(FACTS.Framework.DAL.DbContext dbContext, PaymentMainDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((PaymentMain)dtoEntities[dto]);
            }

            PaymentMain entity = new PaymentMain();

            dtoEntities.Add(dto, entity);

            entity.AgentId                = dto.AgentId;
            entity.BankAccountNumber      = dto.BankAccountNumber;
            entity.BankAccountTypeCode    = dto.BankAccountTypeCode;
            entity.CreateDateTime         = dto.CreateDateTime;
            entity.CreateUserId           = dto.CreateUserId;
            entity.EmployerId             = dto.EmployerId;
            entity.IsAgent                = dto.IsAgent;
            entity.PaymentAmount          = dto.PaymentAmount;
            entity.PaymentMainId          = dto.PaymentMainId;
            entity.PaymentMethodCode      = dto.PaymentMethodCode;
            entity.PaymentStatusCode      = dto.PaymentStatusCode;
            entity.PaymentStatusDate      = dto.PaymentStatusDate;
            entity.PaymentSubmittedDate   = dto.PaymentSubmittedDate;
            entity.PaymentTransactionDate = dto.PaymentTransactionDate;
            entity.RoutingTransitNumber   = dto.RoutingTransitNumber;
            entity.UpdateDateTime         = dto.UpdateDateTime;
            entity.UpdateNumber           = dto.UpdateNumber;
            entity.UpdateProcess          = dto.UpdateProcess;
            entity.UpdateUserId           = dto.UpdateUserId;

            entity.Employer = (dto.Employer == null) ? null : Employer.FromDto(dbContext, dto.Employer, dtoEntities);

            if (dbContext != null)
            {
                dbContext.Entry(entity).State = (dto.IsNew ? EntityState.Added : (dto.IsDeleted ? EntityState.Deleted : EntityState.Modified));
            }

            return(entity);
        }
예제 #5
0
        /// <summary>Convert from PaymentMain entity to DTO</summary>
        /// <param name="dbContext">DB Context to use for setting DTO state</param>
        /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param>
        /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant PaymentMain DTO</returns>
        public PaymentMainDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, PaymentMainDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null)
        {
            entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>();
            if (entityDtos.ContainsKey(this))
            {
                return((PaymentMainDto)entityDtos[this]);
            }

            dto = ToDto(dto);
            entityDtos.Add(this, dto);

            System.Data.Entity.Infrastructure.DbEntityEntry <PaymentMain> entry = dbContext?.Entry(this);
            dto.IsNew     = (entry?.State == EntityState.Added);
            dto.IsDeleted = (entry?.State == EntityState.Deleted);

            if (entry?.Reference(x => x.Employer)?.IsLoaded == true)
            {
                dto.Employer = Employer?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }

            return(dto);
        }
예제 #6
0
        protected static void FromDtoSet(FACTS.Framework.DAL.DbContext dbContext, PaymentMainDto dto, PaymentMain entity, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities)
        {
            entity.AgentId                = dto.AgentId;
            entity.BankAccountNumber      = dto.BankAccountNumber;
            entity.BankAccountTypeCode    = dto.BankAccountTypeCode;
            entity.CreateDateTime         = dto.CreateDateTime;
            entity.CreateUserId           = dto.CreateUserId;
            entity.EmployerId             = dto.EmployerId;
            entity.IsAgent                = dto.IsAgent;
            entity.PaymentAmount          = dto.PaymentAmount;
            entity.PaymentMainId          = dto.PaymentMainId;
            entity.PaymentMethodCode      = dto.PaymentMethodCode;
            entity.PaymentStatusCode      = dto.PaymentStatusCode;
            entity.PaymentStatusDate      = dto.PaymentStatusDate;
            entity.PaymentSubmittedDate   = dto.PaymentSubmittedDate;
            entity.PaymentTransactionDate = dto.PaymentTransactionDate;
            entity.RoutingTransitNumber   = dto.RoutingTransitNumber;
            entity.UpdateDateTime         = dto.UpdateDateTime;
            entity.UpdateNumber           = dto.UpdateNumber;
            entity.UpdateProcess          = dto.UpdateProcess;
            entity.UpdateUserId           = dto.UpdateUserId;

            entity.Employer = (dto.Employer == null) ? null : Employer.FromDto(dbContext, dto.Employer, dtoEntities);
        }
예제 #7
0
        public static MakePaymentViewModel GetEmployerDueAmount(int emprAccountID)
        {
            MakePaymentViewModel          LocalPaymentViewModel           = new MakePaymentViewModel();
            EmployerAccountTransactionDto localEmployerAccountTransaction = new EmployerAccountTransactionDto();
            EmployerDto       localEmployerDto       = new EmployerDto();
            PaymentMainDto    localPaymentMainDto    = new PaymentMainDto();
            PaymentProfileDto localPaymentProfileDto = new PaymentProfileDto();

            using (DbContext context = new DbContext())
            {
                localEmployerDto = (from employerDetail in context.Employers
                                    where employerDetail.EmployerId == emprAccountID
                                    select new EmployerDto
                {
                    EmployerId = employerDetail.EmployerId,
                    EntityName = employerDetail.EntityName,
                }).FirstOrDefault();
                if (localEmployerDto != null)
                {
                    localEmployerAccountTransaction = (from emptranDetail in context.EmployerAccountTransactions
                                                       where emptranDetail.EmployerId == localEmployerDto.EmployerId
                                                       select new EmployerAccountTransactionDto
                    {
                        OwedAmount = emptranDetail.OwedAmount,
                        UnpaidAmount = emptranDetail.UnpaidAmount
                    }).FirstOrDefault();

                    localPaymentMainDto = (from pmtMainDetail in context.PaymentMains
                                           where pmtMainDetail.EmployerId == localEmployerAccountTransaction.EmployerId
                                           select new PaymentMainDto
                    {
                        RoutingTransitNumber = pmtMainDetail.RoutingTransitNumber,
                        BankAccountNumber = pmtMainDetail.BankAccountNumber,
                        BankAccountTypeCode = pmtMainDetail.BankAccountTypeCode,
                        PaymentAmount = pmtMainDetail.PaymentAmount,
                        PaymentTransactionDate = pmtMainDetail.PaymentTransactionDate,
                        PaymentMethodCode = pmtMainDetail.PaymentMethodCode,
                        PaymentStatusCode = pmtMainDetail.PaymentStatusCode,
                        PaymentMainId = pmtMainDetail.PaymentMainId
                    }).FirstOrDefault();
                    localPaymentProfileDto = (from pmtProfile in context.PaymentProfiles
                                              where pmtProfile.EmployerId == localPaymentMainDto.EmployerId && pmtProfile.BankAccountNumber == localPaymentMainDto.BankAccountNumber
                                              select new PaymentProfileDto
                    {
                        AgentId = pmtProfile.AgentId,
                        BankAccountNumber = pmtProfile.BankAccountNumber,
                        CreateDateTime = pmtProfile.CreateDateTime,
                        CreateUserId = pmtProfile.CreateUserId,
                        EmployerId = pmtProfile.EmployerId,
                        PaymentAccountTypeCode = pmtProfile.PaymentAccountTypeCode,
                        PaymentProfileId = pmtProfile.PaymentProfileId,
                        PaymentTypeCode = pmtProfile.PaymentTypeCode,
                        RoutingTransitNumber = pmtProfile.RoutingTransitNumber,
                        UpdateDateTime = pmtProfile.UpdateDateTime,
                        UpdateNumber = pmtProfile.UpdateNumber,
                        UpdateUserId = pmtProfile.UpdateUserId,
                    }).FirstOrDefault();
                }
            }
            LocalPaymentViewModel.EmployerAccountTransactionDto = localEmployerAccountTransaction;
            LocalPaymentViewModel.EmployerDto       = localEmployerDto;
            LocalPaymentViewModel.PaymentMainDto    = localPaymentMainDto;
            LocalPaymentViewModel.PaymentProfileDto = localPaymentProfileDto;
            return(LocalPaymentViewModel);
        }