コード例 #1
0
        public static EmployerRegistrationViewModel SubmitRegistration(EmployerRegistrationViewModel employerRegistrationViewModel)
        {
            using (DbContext context = new DbContext())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        employerRegistrationViewModel.EmployerDto        = SetPendingFieldsEmployerDto(employerRegistrationViewModel.EmployerDto, employerRegistrationViewModel.EmployerUnitDto);
                        employerRegistrationViewModel.EmployerContactDto = SetPendingFieldsEmployerContactDto(employerRegistrationViewModel.EmployerContactDto);
                        employerRegistrationViewModel.EmployerUnitDto    = SetPendingFieldsEmployerUnitDto(employerRegistrationViewModel.EmployerUnitDto, employerRegistrationViewModel.ListAddressLinkDto);
                        employerRegistrationViewModel.ListAddressLinkDto = SetPendingFieldsListAddressLinkDto(employerRegistrationViewModel.ListAddressLinkDto);

                        var employer     = Employer.FromDto(context, employerRegistrationViewModel.EmployerDto);
                        var employerUnit = EmployerUnit.FromDto(context, employerRegistrationViewModel.EmployerUnitDto);
                        employer.EmployerContacts.Add(EmployerContact.FromDto(context, employerRegistrationViewModel.EmployerContactDto));
                        foreach (var addressLinkDto in employerRegistrationViewModel.ListAddressLinkDto)
                        {
                            employerUnit.AddressLinks.Add(AddressLink.FromDto(context, addressLinkDto));
                        }
                        employer.EmployerUnits.Add(employerUnit);

                        context.SaveChanges();
                        dbContextTransaction.Commit();
                        employerRegistrationViewModel.EmployerDto = employer.ToDto();
                    }
                    catch (Exception)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
            return(employerRegistrationViewModel);
        }
コード例 #2
0
ファイル: ExampleScreenLogic.cs プロジェクト: Manny35/CICDP
 public static void Save(SecurityPermissionDto securityPermissionDto)
 {
     using (DbContext dbContext = new DbContext())
     {
         SecurityPermission.FromDto(dbContext, securityPermissionDto);
         dbContext.SaveChanges();
     }
 }
コード例 #3
0
 public static List <VoluntaryPlanWaiverRequestDto> SubmitRequest(VoluntaryPlanWaiverRequestDto VPRequestForm)
 {
     ExecuteSubmitRequestRules(VPRequestForm);
     if (Context.ValidationMessages.Count(ValidationMessageSeverity.Error) == 0)
     {
         using (DbContext context = new DbContext())
         {
             VPRequestForm.VoluntaryPlanWaiverRequestTypes.RemoveAll(r => r.LeaveTypeCode == null);
             VoluntaryPlanWaiverRequest.FromDto(context, VPRequestForm);
             context.SaveChanges();
         }
     }
     else
     {
         Context.ValidationMessages.ThrowCheck(ValidationMessageSeverity.Error);
     }
     return(GetRequestColl(VPRequestForm.EmployerId));
 }
コード例 #4
0
        public static List <VPRequestViewModel> SubmitRequest(VPRequestForm VPRequestForm)
        {
            #region Commented
            //VoluntaryPlanWaiverRequestDto obj = new VoluntaryPlanWaiverRequestDto();
            //obj.EmployerId = 1;
            //obj.StartDate = DateTime.Now;
            //obj.EndDate = DateTime.Now;
            //obj.IsVoluntaryPlanWaiverRequestAcknowledged = true;
            //obj.VoluntaryPlanWaiverRequestTypes.Add(new VoluntaryPlanWaiverRequestTypeDto()
            //{
            //	LeaveTypeCode = LookupTable_WaiverLeaveType.Medical,
            //	PercentagePaid = 2,
            //	DurationInWeeksCode = LookupTable_WaiverWeeksAvailable._1Week
            //});
            //obj.VoluntaryPlanWaiverRequestTypes.Add(new VoluntaryPlanWaiverRequestTypeDto()
            //{
            //	LeaveTypeCode = LookupTable_WaiverLeaveType.Medical,
            //	PercentagePaid = 1,
            //	DurationInWeeksCode = LookupTable_WaiverWeeksAvailable._4Weeks
            //});

            //VPRequestForm = new VPRequestForm()
            //{
            //	EmployerId = 1,
            //	StartDate = DateTime.Now,
            //	EndDate = DateTime.Now,
            //	IsAcknolwedged = true,
            //	RequestType = new List<VoluntaryPlanWaiverRequestTypeDto>() {
            //		new VoluntaryPlanWaiverRequestTypeDto()
            //		{
            //			 LeaveTypeCode = LookupTable_WaiverLeaveType.Medical,
            //			  PercentagePaid = 2,
            //			  DurationInWeeksCode = LookupTable_WaiverWeeksAvailable._1Week
            //		},
            //		new VoluntaryPlanWaiverRequestTypeDto()
            //		{
            //			 LeaveTypeCode = LookupTable_WaiverLeaveType.Medical,
            //			  PercentagePaid = 1,
            //			  DurationInWeeksCode = LookupTable_WaiverWeeksAvailable._1Week
            //		}
            //	},
            //	Document = new List<DocumentDto>() {
            //		 new DocumentDto(){
            //			  DocumentDescription="Doc Description",
            //			  DocumentName ="DJ.pdf"
            //		 }
            //	}

            //};
            #endregion

            ExecuteSubmitRequestRules(VPRequestForm);
            if (Context.ValidationMessages.Count(ValidationMessageSeverity.Error) == 0)
            {
                using (DbContext context = new DbContext())
                {
                    FormDto FormReq = new FormDto()
                    {
                        FormTypeCode = LookupTable_FormType.VPWaiverForm,
                        StatusCode   = LookupTable_WaiverRequestStatus.SavedasDraft
                    };
                    Form.FromDto(context, FormReq);

                    VoluntaryPlanWaiverRequestDto VPWReq = new VoluntaryPlanWaiverRequestDto()
                    {
                        EmployerId = VPRequestForm.EmployerId,
                        StartDate  = VPRequestForm.StartDate,
                        EndDate    = VPRequestForm.EndDate,
                        IsVoluntaryPlanWaiverRequestAcknowledged = VPRequestForm.IsAcknolwedged
                    };
                    VoluntaryPlanWaiverRequest.FromDto(context, VPWReq);


                    VPRequestForm.RequestType.RemoveAll(p => string.IsNullOrWhiteSpace(p.LeaveTypeCode));
                    foreach (var requestType in VPRequestForm.RequestType)
                    {
                        VoluntaryPlanWaiverRequestType VPWReqType = new VoluntaryPlanWaiverRequestType()
                        {
                            LeaveTypeCode       = requestType.LeaveTypeCode,
                            PercentagePaid      = requestType.PercentagePaid,
                            DurationInWeeksCode = requestType.DurationInWeeksCode
                        };
                        context.VoluntaryPlanWaiverRequestTypes.Add(VPWReqType);
                    }

                    if (VPRequestForm.Document != null)
                    {
                        foreach (var docItem in VPRequestForm.Document)
                        {
                            Document doc = new Document()
                            {
                                DocumentName        = docItem.DocumentName,
                                ExternalDocumentId  = Guid.NewGuid(),
                                DocumentDescription = docItem.DocumentDescription
                            };
                            context.Documents.Add(doc);
                            context.FormAttachments.Add(new FormAttachment());
                        }
                    }

                    context.SaveChanges();
                }
            }
            else
            {
                Context.ValidationMessages.ThrowCheck(ValidationMessageSeverity.Error);
            }
            return(GetRequestColl(VPRequestForm.EmployerId));
        }
コード例 #5
0
        public static WageSubmissionViewModel ValidateTax(WageSubmissionViewModel wageDetail)
        {
            wageDetail.EmployerAccountTransactionDto.EmployerId       = wageDetail.Employer.EmployerId;
            wageDetail.EmployerAccountTransactionDto.ReportingQuarter = wageDetail.ReportingQuarter;
            wageDetail.EmployerAccountTransactionDto.ReportingYear    = wageDetail.ReportingYear;
            wageDetail.EmployerAccountTransactionDto.TypeCode         = LookupTable_TransactionType.ContributionsPrinciple;
            wageDetail.EmployerAccountTransactionDto.StatusCode       = LookupTable_PaymentStatus.PaymentStatusUnpaid;
            wageDetail.EmployerAccountTransactionDto.DueDate          = DateTimeUtil.Now.AddDays(Convert.ToDouble(LookupTable_PremiumPaymentDueDays.PremiumPaymentDueDays));

            wageDetail.TaxableAmountSumDto.EmployerId         = wageDetail.Employer.EmployerId;
            wageDetail.TaxableAmountSumDto.ReportingQuarter   = wageDetail.ReportingQuarter;
            wageDetail.TaxableAmountSumDto.ReportingYear      = wageDetail.ReportingYear;
            wageDetail.TaxableAmountSumDto.StatusCode         = LookupTable_TaxableAmSumStatus.Submitted;
            wageDetail.TaxableAmountSumDto.TaxableAmountSeqNo = GetMaxTaxableAmountSumSeqNu(wageDetail.Employer.EmployerId, wageDetail.ReportingYear);
            int quaterNumber = Convert.ToInt16(wageDetail.ReportingQuarter.ToString().Remove(0, 1));

            if (quaterNumber == 1)
            {
                wageDetail.TaxableAmountSumDto.Quarter1TaxableAmt = wageDetail.GrossWages;
                wageDetail.TaxableAmountSumDto.Quarter1GrossAmt   = wageDetail.GrossWages;
            }
            if (quaterNumber == 2)
            {
                wageDetail.TaxableAmountSumDto.Quarter2TaxableAmt = wageDetail.GrossWages;
                wageDetail.TaxableAmountSumDto.Quarter2GrossAmt   = wageDetail.GrossWages;
            }
            if (quaterNumber == 3)
            {
                wageDetail.TaxableAmountSumDto.Quarter3TaxableAmt = wageDetail.GrossWages;
                wageDetail.TaxableAmountSumDto.Quarter3GrossAmt   = wageDetail.GrossWages;
            }
            if (quaterNumber == 4)
            {
                wageDetail.TaxableAmountSumDto.Quarter4TaxableAmt = wageDetail.GrossWages;
                wageDetail.TaxableAmountSumDto.Quarter4GrossAmt   = wageDetail.GrossWages;
            }


            using (DbContext context = new DbContext())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        foreach (var wageUnitDetails in wageDetail.ListWageUnitDetailDto.Where(x => x.Ssn != null))
                        {
                            wageUnitDetails.Employer = null;
                            WageUnitDetail.FromDto(context, wageUnitDetails);
                            context.SaveChanges();
                        }

                        EmployerAccountTransaction.FromDto(context, wageDetail.EmployerAccountTransactionDto);
                        context.SaveChanges();

                        TaxableAmountSum.FromDto(context, wageDetail.TaxableAmountSumDto);
                        context.SaveChanges();

                        dbContextTransaction.Commit();
                    }
                    catch (Exception)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }

            return(wageDetail);
        }