Пример #1
0
        public async Task <EmployerDto> GetForLogin(string userName, string password)
        {
            if (userName == null)
            {
                throw new ArgumentNullException("User name null");
            }

            if (password == null)
            {
                throw new ArgumentNullException("Password null");
            }

            var entity = await employerRepository.GetAll()
                         .Where(p => p.Password == password)
                         .Where(p => p.IsActive == true)
                         .FirstOrDefaultAsync(p => p.UserName == userName);

            if (entity == null)
            {
                throw new ArgumentNullException("Not Found");
            }
            else
            {
                var model = new EmployerDto();
                entity.MapTo(model);

                return(model);
            }
        }
Пример #2
0
 public MakePaymentViewModel()
 {
     PaymentMainDto                = new PaymentMainDto();
     PaymentProfileDto             = new PaymentProfileDto();
     EmployerAccountTransactionDto = new EmployerAccountTransactionDto();
     EmployerDto = new EmployerDto();
 }
Пример #3
0
        static Employer CreateNewEmployer(EmployerDto employerDto)
        {
            int      liabilityIncurredYear = employerDto.EmployerLiability.LiabilityAmountMetYear.HasValue ? employerDto.EmployerLiability.LiabilityAmountMetYear.Value : 0;
            int      liabilityIncurredQtr  = employerDto.EmployerLiability.LiabilityAmountMetYear.HasValue ? Convert.ToInt32(employerDto.EmployerLiability.LiabilityAmountMetQuarter) : 0;
            DateTime?liabilityDate         = GetLiabilityDate(liabilityIncurredYear, liabilityIncurredQtr, employerDto.EntityTypeCode, employerDto.EmployerUnits[0].FirstWageDate);
            string   paymentMehtodCode     = GetPaymentMethod();

            Employer employer = new Employer
            {
                Fein                      = employerDto.Fein,
                EntityName                = employerDto.EntityName,
                EntityTypeCode            = employerDto.EntityTypeCode,
                BusinessTypeCode          = employerDto.BusinessTypeCode,
                NoOfEmployeesPaid         = employerDto.NoOfEmployeesPaid,
                ServiceBeginDate          = employerDto.ServiceBeginDate,
                IsIndividualContractor    = employerDto.IsIndividualContractor,
                IsAcquired                = employerDto.IsAcquired,
                IsPresentInMultipleLoc    = employerDto.IsPresentInMultipleLoc,
                IsClientOfPEO             = employerDto.IsClientOfPEO,
                IsApplyingForREIM         = employerDto.IsApplyingForREIM,
                NoOfLocation              = employerDto.NoOfLocation,
                HasPhysicalLocation       = employerDto.HasPhysicalLocation,
                IsExemptUnderIRS501C3     = employerDto.IsExemptUnderIRS501C3,
                IsProfessionalEmployerOrg = employerDto.IsProfessionalEmployerOrg,
                RegistrationDate          = DateTimeUtil.Now,
                LiabilityDate             = liabilityDate,
                LiabilityIncurredDate     = liabilityDate,
                ReportMethodCode          = paymentMehtodCode,
                SubjectivityCode          = GetSubjectivityCode(paymentMehtodCode),
                StatusCode                = LookupTable_EmployerStatus.Active,
                StatusDate                = DateTimeUtil.Now
            };

            return(employer);
        }
Пример #4
0
 public WageSubmissionViewModel()
 {
     ListWageUnitDetailDto       = new List <WageUnitDetailDto>();
     ListWageEmployerUnitSummary = new List <WageDetailSummary>();
     Employer = new EmployerDto();
     EmployerAccountTransactionDto = new EmployerAccountTransactionDto();
 }
 public void Load(EmployerDto employerDto)
 {
     if (employerDto == null)
     {
         return;
     }
     _employerid    = employerDto.EmployerID;
     tbName.Text    = employerDto.Name;
     tbAddress.Text = employerDto.Address;
     if (string.IsNullOrEmpty(employerDto.PhoneNumber) == false)
     {
         tbPhoneNumber.Text = employerDto.PhoneNumber;
     }
     if (employerDto.Work != null)
     {
         foreach (TypeOfWorkDto workDto in Works)
         {
             if (employerDto.Work.WorkID == workDto.WorkID)
             {
                 this.cbTypeOfWork.SelectedItem = workDto;
                 break;
             }
         }
     }
 }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tbName.Text))
            {
                MessageBox.Show("Имя работодателя не может быть пустым", "Проверка");
                return;
            }
            if (string.IsNullOrEmpty(tbAddress.Text))
            {
                MessageBox.Show("Адрес работодателя не может быть пустым", "Проверка");
                return;
            }
            EmployerDto employer = new EmployerDto();

            employer.Name        = tbName.Text;
            employer.Address     = tbAddress.Text;
            employer.PhoneNumber = tbPhoneNumber.Text;
            employer.Work        = cbTypeOfWork.SelectedItem as TypeOfWorkDto;
            IEmployerProcess employerProcess = ProcessFactory.GetEmployerProcess();

            if (_employerid == 0)
            {
                employerProcess.Add(employer);
            }
            else
            {
                employer.EmployerID = _employerid;
                employerProcess.Update(employer);
            }
            Close();
        }
Пример #7
0
        public async Task Update(EmployerDto employer)
        {
            using (var unitOfWork = UnitOfWorkProvider.Create())
            {
                await employerService.Update(employer);

                await unitOfWork.Commit();
            }
        }
Пример #8
0
 public EmployerRegistrationViewModel()
 {
     EmployerDto = new EmployerDto()
     {
         EmployerLiability = new EmployerLiabilityDto(), EmployerPreference = new EmployerPreferenceDto()
     };
     EmployerContactDto = new EmployerContactDto();
     EmployerUnitDto    = new EmployerUnitDto();
     ListAddressLinkDto = new List <AddressLinkDto>();
 }
Пример #9
0
        public async Task <ActionResult> EditCurrentEmployer(EmployerDto employerDto)
        {
            if (ModelState.IsValid)
            {
                await EmployerFacade.Update(employerDto);

                return(RedirectToAction("Index", "Home"));
            }

            return(View("Edit", employerDto));
        }
Пример #10
0
 public EmployerRegistrationViewModel()
 {
     EmployerDto = new EmployerDto()
     {
         EmployerLiability = new EmployerLiabilityDto(), EmployerPreference = new EmployerPreferenceDto(), IsProfessionalEmployerOrg = false, IsClientOfPEO = false, IsIndividualContractor = false, IsExemptUnderIRS501C3 = false, IsApplyingForREIM = false, IsAcquired = false, IsPresentInMultipleLoc = false
     };
     EmployerContactDto = new EmployerContactDto();
     EmployerUnitDto    = new EmployerUnitDto();
     ListAddressLinkDto = new List <AddressLinkDto> {
         new AddressLinkDto()
     };
 }
Пример #11
0
 public static OfferViewModel From(Offer offer)
 {
     return(new OfferViewModel()
     {
         Id = offer.Id,
         Description = offer.Description,
         Employer = EmployerDto.From(offer.Employer),
         OfferType = OfferTypeDto.From(offer.OfferType),
         Active = offer.Active,
         OfferTypeName = offer.OfferType.Name
     });
 }
Пример #12
0
        public async Task DeleteApplication(int id, EmployerDto deletingEmployer)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                if ((await jobApplicationService.GetAsync(id)).JobOffer.Employer.Id != deletingEmployer.Id)
                {
                    throw new ArgumentException();
                }

                jobApplicationService.Delete(id);
                await uow.Commit();
            }
        }
Пример #13
0
        private void btnEditEmployer_Click(object sender, RoutedEventArgs e)
        {
            EmployerDto item = dgEmployer.SelectedItem as EmployerDto;

            if (item == null)
            {
                MessageBox.Show("Выберите запись для редактирования", "Редактирование работодателей");
            }
            AddEmployerWindow window = new AddEmployerWindow();

            window.Load(item);
            window.ShowDialog();
            btnRefresh_Click(sender, e);
        }
Пример #14
0
        public static Employer Convert(EmployerDto employerDto)
        {
            if (employerDto == null)
            {
                return(null);
            }
            Employer employer = new Employer();

            employer.EmployerID  = employerDto.EmployerID;
            employer.Name        = employerDto.Name;
            employer.Address     = employerDto.Address;
            employer.PhoneNumber = employerDto.PhoneNumber;
            employer.WorkID      = employerDto.Work.WorkID;
            return(employer);
        }
Пример #15
0
        //
        // EMPLOYER
        //
        public static EmployerDto Convert(Employer employer)
        {
            if (employer == null)
            {
                return(null);
            }
            EmployerDto employerDto = new EmployerDto();

            employerDto.EmployerID  = employer.EmployerID;
            employerDto.Name        = employer.Name;
            employerDto.Address     = employer.Address;
            employerDto.PhoneNumber = employer.PhoneNumber;
            employerDto.Work        = Convert(DaoFactory.GetTypeOfWorkDao().Get(employer.WorkID));
            return(employerDto);
        }
Пример #16
0
        public async Task <bool> AcceptOnlyThisApplication(int applicationId, EmployerDto managingEmployer)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                if ((await jobApplicationService.GetAsync(applicationId)).JobOffer.Employer.Id != managingEmployer.Id)
                {
                    throw new ArgumentException();
                }

                var result = await jobApplicationService.AcceptOnlyThisApplication(applicationId);

                await uow.Commit();

                return(result);
            }
        }
Пример #17
0
        private void btnDeleteEmployer_Click(object sender, RoutedEventArgs e)
        {
            EmployerDto item = dgEmployer.SelectedItem as EmployerDto;

            if (item == null)
            {
                MessageBox.Show("Выберите запись для удаления", "Удаление работодателей");
            }
            MessageBoxResult result = MessageBox.Show("Удалить работодателя: " + item.Name + "?", "Удаление работодателей", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            ProcessFactory.GetEmployerProcess().Delete(item.EmployerID);
            btnRefresh_Click(sender, e);
        }
Пример #18
0
        /// <summary>
        /// Set Pending Fields for EmployerDto
        /// </summary>
        /// <param name="employerDto"></param>
        /// <param name="employerUnitDto"></param>
        /// <returns></returns>
        private static EmployerDto SetPendingFieldsEmployerDto(EmployerDto employerDto, EmployerUnitDto employerUnitDto)
        {
            var      employerLiabilityDto  = employerDto.EmployerLiability;
            int      liabilityIncurredYear = employerLiabilityDto.LiabilityAmountMetYear.HasValue ? employerLiabilityDto.LiabilityAmountMetYear.Value : 0;
            int      liabilityIncurredQtr  = employerLiabilityDto.LiabilityAmountMetYear.HasValue ? Convert.ToInt32(DateUtil.GetQuarterNumber(employerLiabilityDto.LiabilityAmountMetQuarter)) : 0;
            DateTime?liabilityDate         = GetLiabilityDate(liabilityIncurredYear, liabilityIncurredQtr, employerDto.EntityTypeCode, employerUnitDto.FirstWageDate);
            string   paymentMehtodCode     = GetPaymentMethod();

            employerDto.RegistrationDate      = DateTimeUtil.Now;
            employerDto.LiabilityDate         = liabilityDate;
            employerDto.LiabilityIncurredDate = liabilityDate;
            employerDto.ReportMethodCode      = paymentMehtodCode;
            employerDto.SubjectivityCode      = GetSubjectivityCode(paymentMehtodCode);
            employerDto.StatusCode            = LookupTable_EmployerStatus.Active;
            employerDto.StatusDate            = DateTimeUtil.Now;

            return(employerDto);
        }
Пример #19
0
        public IList <EmployerDto> ListEmployer()
        {
            var users = _db2.AspNetUsers.ToList();
            IList <EmployerDto> userList = new List <EmployerDto>();

            foreach (var user in users)
            {
                if (user.Employer != null)
                {
                    var list = new EmployerDto()
                    {
                        Id            = user.Id,
                        Address       = user.Address,
                        DateOfBirth   = user.DateOfBirth.ToString(),
                        Email         = user.Email,
                        FirstName     = user.FirstName,
                        LastName      = user.LastName,
                        MiddleName    = user.MiddleName,
                        PhoneNumber   = user.PhoneNumber,
                        PlaceOfBirth  = user.PlaceOfBirth,
                        StateOfOrigin = user.StateOfOrigin,

                        EmploymentIdNumber   = user.Employer.EmploymentIdNumber,
                        NextOfKin            = user.Employer.NextOfKin,
                        NextOfKinAddress     = user.Employer.NextOfKinAddress,
                        NextOfKinPhoneNumber = user.Employer.NextOfKinPhoneNumber,
                        PlaceOfWork          = user.Employer.PlaceOfWork,
                        Profession           = user.Employer.Profession
                    };

                    if (user.Sex == SexType.Male)
                    {
                        list.Sex = "Male";
                    }
                    else
                    {
                        list.Sex = "Female";
                    }
                    userList.Add(list);
                }
            }
            return(userList);
        }
Пример #20
0
        /// <summary>Convert from Employer 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 Employer entity</returns>
        public static Employer FromDto(FACTS.Framework.DAL.DbContext dbContext, EmployerDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((Employer)dtoEntities[dto]);
            }

            Employer entity = new Employer();

            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);
        }
Пример #21
0
        public async Task <bool> EditJobOffer(JobOfferCreateDto jobOffer, EmployerDto editor)
        {
            if (editor.Id != jobOffer.EmployerId)
            {
                throw new ArgumentException();
            }

            using (var uow = UnitOfWorkProvider.Create())
            {
                if ((await jobOfferService.GetAsync(jobOffer.Id, false)) == null)
                {
                    return(false);
                }
                await jobOfferService.Update(jobOffer);

                await uow.Commit();

                return(true);
            }
        }
Пример #22
0
        /// <summary>Convert from Employer 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 Employer DTO</returns>
        public EmployerDto ToDto(EmployerDto dto = null)
        {
            dto       = dto ?? new EmployerDto();
            dto.IsNew = false;

            dto.BusinessTypeCode          = BusinessTypeCode;
            dto.CreateDateTime            = CreateDateTime;
            dto.CreateUserId              = CreateUserId;
            dto.EmployerId                = EmployerId;
            dto.EntityName                = EntityName;
            dto.EntityTypeCode            = EntityTypeCode;
            dto.Fein                      = Fein;
            dto.HasPhysicalLocation       = HasPhysicalLocation;
            dto.HasTelecommuter           = HasTelecommuter;
            dto.IsAcquired                = IsAcquired;
            dto.IsApplyingForREIM         = IsApplyingForREIM;
            dto.IsClientOfPEO             = IsClientOfPEO;
            dto.IsExemptUnderIRS501C3     = IsExemptUnderIRS501C3;
            dto.IsIndividualContractor    = IsIndividualContractor;
            dto.IsPresentInMultipleLoc    = IsPresentInMultipleLoc;
            dto.IsProfessionalEmployerOrg = IsProfessionalEmployerOrg;
            dto.IsServiceBegin            = IsServiceBegin;
            dto.LiabilityDate             = LiabilityDate;
            dto.LiabilityIncurredDate     = LiabilityIncurredDate;
            dto.NoOfEmployeesPaid         = NoOfEmployeesPaid;
            dto.NoOfLocation              = NoOfLocation;
            dto.RegistrationDate          = RegistrationDate;
            dto.ReportMethodCode          = ReportMethodCode;
            dto.ServiceBeginDate          = ServiceBeginDate;
            dto.StatusCode                = StatusCode;
            dto.StatusDate                = StatusDate;
            dto.SubjectivityCode          = SubjectivityCode;
            dto.UpdateDateTime            = UpdateDateTime;
            dto.UpdateNumber              = UpdateNumber;
            dto.UpdateProcess             = UpdateProcess;
            dto.UpdateUserId              = UpdateUserId;
            dto.UserName                  = UserName;

            return(dto);
        }
Пример #23
0
        public async Task <bool> DeleteJobOffer(int entityId, EmployerDto editor)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                var jobOffer = await jobOfferService.GetAsync(entityId, false);

                if (jobOffer == null)
                {
                    return(false);
                }

                if (editor.Id != jobOffer.EmployerId)
                {
                    throw new ArgumentException();
                }

                jobOfferService.Delete(entityId);
                await uow.Commit();

                return(true);
            }
        }
        public async Task GetEmployerAccordingToNameAsync_ExistingEmployer_ReturnsCorrectEmployer()
        {
            const string name             = "Dilino";
            var          expectedEmployer = new EmployerDto()
            {
                Id          = 1,
                Name        = name,
                Email       = "*****@*****.**",
                Address     = ":D",
                PhoneNumber = "+421910987654"
            };
            var expectedQueryResult =
                new QueryResultDto <EmployerDto, EmployerFilterDto> {
                Items = new List <EmployerDto> {
                    expectedEmployer
                }
            };
            var customerFacade = CreateFacade(expectedQueryResult);

            var actualCustomer = await customerFacade.GetEmployerByName(name);

            Assert.AreEqual(actualCustomer, expectedEmployer);
        }
 public void Add(EmployerDto employer)
 {
     employerDao.Add(DtoConverter.Convert(employer));
 }
Пример #26
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);
        }
Пример #27
0
        protected static void FromDtoSet(FACTS.Framework.DAL.DbContext dbContext, EmployerDto dto, Employer entity, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities)
        {
            entity.BusinessTypeCode          = dto.BusinessTypeCode;
            entity.CreateDateTime            = dto.CreateDateTime;
            entity.CreateUserId              = dto.CreateUserId;
            entity.EmployerId                = dto.EmployerId;
            entity.EntityName                = dto.EntityName;
            entity.EntityTypeCode            = dto.EntityTypeCode;
            entity.Fein                      = dto.Fein;
            entity.HasPhysicalLocation       = dto.HasPhysicalLocation;
            entity.HasTelecommuter           = dto.HasTelecommuter;
            entity.IsAcquired                = dto.IsAcquired;
            entity.IsApplyingForREIM         = dto.IsApplyingForREIM;
            entity.IsClientOfPEO             = dto.IsClientOfPEO;
            entity.IsExemptUnderIRS501C3     = dto.IsExemptUnderIRS501C3;
            entity.IsIndividualContractor    = dto.IsIndividualContractor;
            entity.IsPresentInMultipleLoc    = dto.IsPresentInMultipleLoc;
            entity.IsProfessionalEmployerOrg = dto.IsProfessionalEmployerOrg;
            entity.IsServiceBegin            = dto.IsServiceBegin;
            entity.LiabilityDate             = dto.LiabilityDate;
            entity.LiabilityIncurredDate     = dto.LiabilityIncurredDate;
            entity.NoOfEmployeesPaid         = dto.NoOfEmployeesPaid;
            entity.NoOfLocation              = dto.NoOfLocation;
            entity.RegistrationDate          = dto.RegistrationDate;
            entity.ReportMethodCode          = dto.ReportMethodCode;
            entity.ServiceBeginDate          = dto.ServiceBeginDate;
            entity.StatusCode                = dto.StatusCode;
            entity.StatusDate                = dto.StatusDate;
            entity.SubjectivityCode          = dto.SubjectivityCode;
            entity.UpdateDateTime            = dto.UpdateDateTime;
            entity.UpdateNumber              = dto.UpdateNumber;
            entity.UpdateProcess             = dto.UpdateProcess;
            entity.UpdateUserId              = dto.UpdateUserId;
            entity.UserName                  = dto.UserName;

            if (dto.AddressLinks != null)
            {
                foreach (AddressLinkDto addressLink in dto.AddressLinks)
                {
                    entity.AddressLinks.Add(DbEntities.AddressLink.FromDto(dbContext, addressLink, dtoEntities));
                }
            }
            if (dto.EmployerAccountTransactions != null)
            {
                foreach (EmployerAccountTransactionDto employerAccountTransaction in dto.EmployerAccountTransactions)
                {
                    entity.EmployerAccountTransactions.Add(DbEntities.EmployerAccountTransaction.FromDto(dbContext, employerAccountTransaction, dtoEntities));
                }
            }
            if (dto.EmployerContacts != null)
            {
                foreach (EmployerContactDto employerContact in dto.EmployerContacts)
                {
                    entity.EmployerContacts.Add(DbEntities.EmployerContact.FromDto(dbContext, employerContact, dtoEntities));
                }
            }
            entity.EmployerLiability  = (dto.EmployerLiability == null) ? null : EmployerLiability.FromDto(dbContext, dto.EmployerLiability, dtoEntities);
            entity.EmployerPreference = (dto.EmployerPreference == null) ? null : EmployerPreference.FromDto(dbContext, dto.EmployerPreference, dtoEntities);
            if (dto.EmployerUnits != null)
            {
                foreach (EmployerUnitDto employerUnit in dto.EmployerUnits)
                {
                    entity.EmployerUnits.Add(DbEntities.EmployerUnit.FromDto(dbContext, employerUnit, dtoEntities));
                }
            }
            if (dto.PaymentMains != null)
            {
                foreach (PaymentMainDto paymentMain in dto.PaymentMains)
                {
                    entity.PaymentMains.Add(DbEntities.PaymentMain.FromDto(dbContext, paymentMain, dtoEntities));
                }
            }
            if (dto.PaymentProfiles != null)
            {
                foreach (PaymentProfileDto paymentProfile in dto.PaymentProfiles)
                {
                    entity.PaymentProfiles.Add(DbEntities.PaymentProfile.FromDto(dbContext, paymentProfile, dtoEntities));
                }
            }
            if (dto.TaxableAmountSums != null)
            {
                foreach (TaxableAmountSumDto taxableAmountSum in dto.TaxableAmountSums)
                {
                    entity.TaxableAmountSums.Add(DbEntities.TaxableAmountSum.FromDto(dbContext, taxableAmountSum, dtoEntities));
                }
            }
            if (dto.VoluntaryPlanWaiverRequests != null)
            {
                foreach (VoluntaryPlanWaiverRequestDto voluntaryPlanWaiverRequest in dto.VoluntaryPlanWaiverRequests)
                {
                    entity.VoluntaryPlanWaiverRequests.Add(DbEntities.VoluntaryPlanWaiverRequest.FromDto(dbContext, voluntaryPlanWaiverRequest, dtoEntities));
                }
            }
            if (dto.WageUnitDetails != null)
            {
                foreach (WageUnitDetailDto wageUnitDetail in dto.WageUnitDetails)
                {
                    entity.WageUnitDetails.Add(DbEntities.WageUnitDetail.FromDto(dbContext, wageUnitDetail, dtoEntities));
                }
            }
        }
Пример #28
0
 public Boolean insertEmployer(EmployerDto dto)
 {
     Employer obj = Employer.createEmployer(dto.EmployerId, dto.EmployerName);
     EmployerManager mgr = new EmployerManager();
     return mgr.insertEmployer(obj);
 }
 public void Update(EmployerDto employer)
 {
     employerDao.Update(DtoConverter.Convert(employer));
 }
Пример #30
0
        /// <summary>Convert from Employer 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 Employer DTO</returns>
        public EmployerDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, EmployerDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null)
        {
            entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>();
            if (entityDtos.ContainsKey(this))
            {
                return((EmployerDto)entityDtos[this]);
            }

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

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

            if (entry?.Collection(x => x.AddressLinks)?.IsLoaded == true)
            {
                foreach (AddressLink addressLink in AddressLinks)
                {
                    dto.AddressLinks.Add(addressLink.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }
            if (entry?.Collection(x => x.EmployerAccountTransactions)?.IsLoaded == true)
            {
                foreach (EmployerAccountTransaction employerAccountTransaction in EmployerAccountTransactions)
                {
                    dto.EmployerAccountTransactions.Add(employerAccountTransaction.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }
            if (entry?.Collection(x => x.EmployerContacts)?.IsLoaded == true)
            {
                foreach (EmployerContact employerContact in EmployerContacts)
                {
                    dto.EmployerContacts.Add(employerContact.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }
            if (entry?.Reference(x => x.EmployerLiability)?.IsLoaded == true)
            {
                dto.EmployerLiability = EmployerLiability?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }
            if (entry?.Reference(x => x.EmployerPreference)?.IsLoaded == true)
            {
                dto.EmployerPreference = EmployerPreference?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }
            if (entry?.Collection(x => x.EmployerUnits)?.IsLoaded == true)
            {
                foreach (EmployerUnit employerUnit in EmployerUnits)
                {
                    dto.EmployerUnits.Add(employerUnit.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }
            if (entry?.Collection(x => x.PaymentMains)?.IsLoaded == true)
            {
                foreach (PaymentMain paymentMain in PaymentMains)
                {
                    dto.PaymentMains.Add(paymentMain.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }
            if (entry?.Collection(x => x.PaymentProfiles)?.IsLoaded == true)
            {
                foreach (PaymentProfile paymentProfile in PaymentProfiles)
                {
                    dto.PaymentProfiles.Add(paymentProfile.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }
            if (entry?.Collection(x => x.TaxableAmountSums)?.IsLoaded == true)
            {
                foreach (TaxableAmountSum taxableAmountSum in TaxableAmountSums)
                {
                    dto.TaxableAmountSums.Add(taxableAmountSum.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }
            if (entry?.Collection(x => x.VoluntaryPlanWaiverRequests)?.IsLoaded == true)
            {
                foreach (VoluntaryPlanWaiverRequest voluntaryPlanWaiverRequest in VoluntaryPlanWaiverRequests)
                {
                    dto.VoluntaryPlanWaiverRequests.Add(voluntaryPlanWaiverRequest.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }
            if (entry?.Collection(x => x.WageUnitDetails)?.IsLoaded == true)
            {
                foreach (WageUnitDetail wageUnitDetail in WageUnitDetails)
                {
                    dto.WageUnitDetails.Add(wageUnitDetail.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }

            return(dto);
        }
        public void fillExcelByType(IEnumerable <object> grid, string status, FileInfo xlsxFile)
        {
            try
            {
                if (grid != null)
                {
                    ExcelPackage pck         = new ExcelPackage(xlsxFile);
                    var          excel       = pck.Workbook.Worksheets.Add(status);
                    int          x           = 1;
                    int          y           = 1;
                    CultureInfo  cultureInfo = new CultureInfo(Thread.CurrentThread.CurrentCulture.Name);
                    Thread.CurrentThread.CurrentCulture             = cultureInfo;
                    cultureInfo.NumberFormat.NumberDecimalSeparator = ".";
                    // Первая строка (шапка таблицы) – жирным стилем.
                    excel.Cells["A1:Z1"].Style.Font.Bold = true;
                    // Выравнивание текста в ячейках – по левому краю.
                    excel.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                    // Устанавливает формат ячеек.
                    excel.Cells.Style.Numberformat.Format = "General";

                    Object dtObj = new Object();
                    switch (status)
                    {
                    case "JobSeeker":
                        dtObj = new JobSeekerDto();
                        break;

                    case "TypeOfWork":
                        dtObj = new TypeOfWorkDto();
                        break;

                    case "Employer":
                        dtObj = new EmployerDto();
                        break;

                    case "Position":
                        dtObj = new PositionDto();
                        break;

                    case "Deal":
                        dtObj = new DealDto();
                        break;
                    }
                    // Генерация шапки таблицы
                    foreach (var prop in dtObj.GetType().GetProperties())
                    {
                        excel.Cells[y, x].Value = prop.Name.Trim();
                        x++;
                    }
                    // Генерация строк-записей таблицы.
                    foreach (var item in grid)
                    {
                        y++;
                        Object itemObj = item;
                        x = 1;
                        foreach (var prop in itemObj.GetType().GetProperties())
                        {
                            object t = prop.GetValue(itemObj, null);
                            object val;
                            if (t == null)
                            {
                                val = "";
                            }
                            else
                            {
                                val = t.ToString();
                                if (t is TypeOfWorkDto)
                                {
                                    val = ((TypeOfWorkDto)t).Name;
                                }
                                if (t is JobSeekerDto)
                                {
                                    val = ((JobSeekerDto)t).FullName;
                                }
                                if (t is EmployerDto)
                                {
                                    val = ((EmployerDto)t).Name;
                                }
                                if (t is PositionDto)
                                {
                                    val = ((PositionDto)t).PositionName;
                                }
                            }
                            excel.Cells[y, x].Value = val;
                            x++;
                        }
                    }
                    excel.Cells.AutoFitColumns();
                    pck.Save();
                }
                else
                {
                    MessageBox.Show("Данные не загружены!");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString(), "ERROR");
                throw new Exception();
            }
        }
Пример #32
0
 public EmployerDto selectEmployerById(EmployerDto dto)
 {
     EmployerManager mgr = new EmployerManager();
     Employer obj = new Employer();
     obj.EmployerId = dto.EmployerId;
     obj = mgr.selectEmployerById(obj);
     if (obj != null)
     {
         return EmployerDto.createEmployerDTO(obj);
     }
     else
     {
         return null;
     }
 }