Beispiel #1
0
 public static List <Employer> Search(string name)
 {
     using (DbContext dbContext = new DbContext())
     {
         return(new List <Employer>()
         {
             new Employer()
             {
                 AccountNumber = "EMP001", ID = 1, Name = "Deloitte", AccountProfile = "Active"
             },
             new Employer()
             {
                 AccountNumber = "EMP002", ID = 2, Name = "Deloitte2", AccountProfile = "Active"
             },
             new Employer()
             {
                 AccountNumber = "EMP003", ID = 3, Name = "Deloitte3", AccountProfile = "Active"
             },
             new Employer()
             {
                 AccountNumber = "EMP004", ID = 4, Name = "Deloitte4", AccountProfile = "Active"
             }
         });
     }
 }
        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);
        }
Beispiel #3
0
        public static Employer GetEmployer(int ID)
        {
            using (DbContext dbContext = new DbContext())
            {
                List <Employer> obj = new List <Employer>()
                {
                    new Employer()
                    {
                        AccountNumber = "EMP001", ID = 1, Name = "Deloitte", AccountProfile = "Active", EAN = "EAN10010", FEIN = "FEIN3002", LiabilityDate = DateTime.Now, LiabilityIncurred = DateTime.Now.AddDays(10), PaymentMethodType = "Contributory", ChangePaymentMethod = false, HistoryTransfer = true, Successor = false, InitiatedExistingSelfService = false, InitiatedForWageClaim = true, NMPRC = "NMPRC01002", CRS = "CRS0100"
                    },
                    new Employer()
                    {
                        AccountNumber = "EMP002", ID = 2, Name = "Deloitte2", AccountProfile = "Active"
                    },
                    new Employer()
                    {
                        AccountNumber = "EMP003", ID = 3, Name = "Deloitte3", AccountProfile = "Active"
                    },
                    new Employer()
                    {
                        AccountNumber = "EMP004", ID = 4, Name = "Deloitte4", AccountProfile = "Active"
                    }
                };

                return(obj.Where(i => i.ID == ID).FirstOrDefault());
            }
        }
Beispiel #4
0
        public static WageSubmissionViewModel GetWagePeriod()
        {
            WageSubmissionViewModel wage = new WageSubmissionViewModel();

            wage.ReportingYear    = (short)DateTimeUtil.Now.Year;
            wage.ContributionRate = GetCurrentContributionRate();

            using (DbContext context = new DbContext())
            {
                //To do Map the Employerid from context.
                //wage.Employer = context.Employers.FirstOrDefault(emp => emp.EmployerId == 19).ToDto();
                wage.Employer = context.Employers.FirstOrDefault().ToDto();
            }

            for (int i = 1; i <= 25; i++)
            {
                WageSubmissionViewModel.WageUnitCustomDto wageUnitDetailDto = new WageSubmissionViewModel.WageUnitCustomDto();
                wageUnitDetailDto.SrNo       = i;
                wageUnitDetailDto.EmployerId = wage.Employer.EmployerId;
                wageUnitDetailDto.Employer   = wage.Employer;
                wage.ListWageUnitDetailDto.Add(wageUnitDetailDto);
            }

            return(wage);
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="EmployerId"></param>
        /// <returns></returns>
        internal static List <VPRequestViewModel> GetRequestColl(int?EmployerId)
        {
            if (EmployerId is null)
            {
                return(new List <VPRequestViewModel>());
            }
            else
            {
                using (DbContext context = new DbContext())
                {
                    var query = (from req in context.VoluntaryPlanWaiverRequests
                                 from form in context.Forms
                                 where req.EmployerId == EmployerId && req.FormId == form.FormId
                                 select new VPRequestViewModel
                    {
                        RequestId = req.VoluntaryPlanWaiverRequestId,
                        StartDate = req.StartDate,
                        EndDate = req.EndDate,
                        StatusCode = form.StatusCode
                    })?.ToList();

                    return(query);
                }
            }
        }
Beispiel #6
0
 public static void Save(SecurityPermissionDto securityPermissionDto)
 {
     using (DbContext dbContext = new DbContext())
     {
         SecurityPermission.FromDto(dbContext, securityPermissionDto);
         dbContext.SaveChanges();
     }
 }
Beispiel #7
0
 public static VoluntaryPlanWaiverRequestDto GetRequest(VoluntaryPlanWaiverRequestDto VoluntaryPlanWaiverRequestDto)
 {
     using (DbContext context = new DbContext())
     {
         var record = (from vpwr in context.VoluntaryPlanWaiverRequests.Include("VoluntaryPlanWaiverRequestTypes").Include("Form.FormAttachments.Document")
                       where vpwr.FormId == VoluntaryPlanWaiverRequestDto.FormId
                       select vpwr).FirstOrDefault();
         return(record.ToDtoDeep(context));
     }
 }
 public static EmployerRegistrationViewModel ValidateIntroduction(EmployerRegistrationViewModel employerRegistrationViewModel)
 {
     using (DbContext context = new DbContext())
     {
         if (context.Employers.Any(emp => emp.Fein == employerRegistrationViewModel.EmployerDto.Fein))
         {
             Context.ValidationMessages.AddError("The FEIN entered already exists in the system for another employer account. Verify your records to ensure the information you entered is correct and re-enter the FEIN.");
         }
     }
     return(employerRegistrationViewModel);
 }
 public static EmployerRegistrationViewModel ValidateAdminInfo(EmployerRegistrationViewModel employerRegistrationViewModel)
 {
     using (DbContext context = new DbContext())
     {
         if (context.Employers.Any(emp => emp.UserName == employerRegistrationViewModel.EmployerDto.UserName))
         {
             Context.ValidationMessages.AddError("The Username entered already exists in the system for another employer account. Please re-enter different Username.");
         }
     }
     return(employerRegistrationViewModel);
 }
Beispiel #10
0
        /// <summary>
        /// GeNext TaxableAmountSum SeqNumber
        /// </summary>
        /// <param name="emprAcctId"></param>
        /// <param name="rptYr"></param>
        /// <param name="rptQtr"></param>
        /// <returns></returns>
        public static short GetMaxTaxableAmountSumSeqNu(int emprAcctId, short rptYr)
        {
            short maxTaxableSeqNu;

            using (DbContext context = new DbContext())
            {
                maxTaxableSeqNu = context.TaxableAmountSums.Where(x => x.EmployerId == emprAcctId && x.ReportingYear == rptYr).OrderByDescending(X => X.TaxableAmountSeqNo).Select(x => x.TaxableAmountSeqNo).FirstOrDefault();
            }

            return(++maxTaxableSeqNu);
        }
Beispiel #11
0
 public static List <SecurityPermissionDto> Search(string sourceType, string sourceName, string targetType, string targetName, string accessType)
 {
     using (DbContext dbContext = new DbContext())
     {
         var query = dbContext.SecurityPermissions
                     .ConditionalWhere(sourceType, x => x.SourceType == sourceType)
                     .ConditionalWhere(sourceName, x => x.SourceName == sourceName)
                     .ConditionalWhere(targetType, x => x.TargetType == targetType)
                     .ConditionalWhere(targetName, x => x.TargetName == targetName)
                     .ConditionalWhere(accessType, x => x.AccessType == accessType);
         return(query.ToDtoList());
     }
 }
Beispiel #12
0
        /// <summary>
        /// Get Current Tax Rate.
        /// </summary>
        /// <returns></returns>
        public static decimal GetCurrentContributionRate()
        {
            DateTime currentdate = DateTimeUtil.Now;

            using (DbContext context = new DbContext())
            {
                var taxRate = (from rates in context.TaxRates
                               where rates.EffectiveBeginDate <= currentdate & currentdate <= rates.EffectiveEndDate
                               select rates._TaxRate).FirstOrDefault();


                return(Convert.ToDecimal(taxRate));
            }
        }
Beispiel #13
0
        public static WageSubmissionViewModel ValidateSelectionMethod(WageSubmissionViewModel wageDetail)
        {
            using (DbContext context = new DbContext())
            {
                if (context.TaxableAmountSums.Any(x => x.ReportingQuarter == wageDetail.ReportingQuarter && x.ReportingYear == wageDetail.ReportingYear && x.EmployerId == wageDetail.Employer.EmployerId))
                {
                    Context.ValidationMessages.AddError("Original Employment and Wage Detail Report for this year " + wageDetail.ReportingYear + " and quarter " + LookupUtil.GetLookupCode(LookupTable.Quarter, wageDetail.ReportingQuarter).Display + " has already been submitted");
                }
            }

            wageDetail.AdjReasonDisplay = LookupUtil.GetLookupCode(LookupTable.WageDetailAdjReasonCode, LookupTable_WageDetailAdjReasonCode.Original).Display.ToString();
            wageDetail.AdjReasonCode    = LookupTable_WageDetailAdjReasonCode.Original;

            return(wageDetail);
        }
Beispiel #14
0
        public static Record Fetch(int id)
        {
            using (DbContext context = new DbContext())
            {
                //var query = (from p in context.People
                //             let a = p.Addresses.FirstOrDefault()
                //             let pc_email = p.PersonContacts.Where(pc => pc.InvalidContactInfoInd == "N" && pc.PersonContactTypeCode == LookupTable_PersonContactType.EmailAddress).OrderByDescending(pc => pc.PreferredContactInd).FirstOrDefault()
                //             let pc_phone = p.PersonContacts.Where(pc => pc.InvalidContactInfoInd == "N" && (pc.PersonContactTypeCode == LookupTable_PersonContactType.HomePhoneNumber || pc.PersonContactTypeCode == LookupTable_PersonContactType.MobilePhoneNumber)).OrderByDescending(pc => pc.PreferredContactInd).FirstOrDefault()
                //             orderby p.LastName, p.FirstName, p.MiddleName
                //             where p.PersonID == id
                //             select new
                //             {
                //                 p.FirstName,
                //                 p.LastName,
                //                 p.MiddleName,
                //                 p.SuffixCode,
                //                 a.Line1Address,
                //                 a.Line2Address,
                //                 a.City,
                //                 a.StateCode,
                //                 Postal = a.ZipCode,
                //                 Record = new Record
                //                 {
                //                     ID = p.PersonID,
                //                     Ssn = p.SsnEinID,
                //                     DateOfBirth = p.BirthDate,
                //                     DateOfDeath = p.DeathDate,
                //                     GenderCode = p.GenderCode,
                //                     Email = pc_email.PersonContactTypeText,
                //                     Phone = pc_phone.PersonContactTypeText
                //                 }
                //             });

                //var record = query.FirstOrDefault();

                //if (record != null)
                //{
                //    record.Record.Name = StringUtil.FormatName(record.FirstName, record.MiddleName, record.LastName, record.SuffixCode);
                //    record.Record.FormattedAddressLine1 = record.Line2Address;
                //    record.Record.FormattedAddressLine2 = record.City;
                //    record.Record.FormattedAddressLine2 += (!string.IsNullOrEmpty(record.Record.FormattedAddressLine2) ? ", " : "") + record.StateCode;
                //    record.Record.FormattedAddressLine2 += (!string.IsNullOrEmpty(record.Record.FormattedAddressLine2) ? " " : "") + FormatterUtil.Format(Formatter.Postal, record.Postal);
                //}

                //return record.Record;
                return(null);
            }
        }
Beispiel #15
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));
 }
Beispiel #16
0
        public static Record Fetch(int id)
        {
            using (DbContext context = new DbContext())
            {
                //var query = (from a in context.Agencies
                //             where a.AgencyID == id
                //             select new Record
                //             {
                //                 ID = a.AgencyID,
                //                 Name = a.AgencyName,
                //                 Code = a.AgencyCode,
                //                 Status = a.StatusCode
                //             });

                //return query.FirstOrDefault();
                return(null);
            }
        }
Beispiel #17
0
        public static List <ResultRecord> Search(SearchCriteria criteria)
        {
            using (DbContext context = new DbContext())
            {
                //var query = (from a in context.Agencies
                //             orderby a.AgencyName
                //             select new ResultRecord
                //             {
                //                Id = a.AgencyID,
                //                Name = a.AgencyName,
                //                Code = a.AgencyCode,
                //                Status = a.StatusCode
                //             });

                //query = query.ConditionalWhere(criteria.Name, q => q.Name.Contains(criteria.Name));

                //query = query.Take(501);
                //return query.ToList();
                return(null);
            }
        }
Beispiel #18
0
        public static List <ResultRecord> Search(SearchCriteria criteria)
        {
            using (DbContext context = new DbContext())
            {
                //var query = (from p in context.People
                //             orderby p.LastName, p.FirstName, p.MiddleName
                //             select new
                //             {
                //                 p.FirstName,
                //                 p.LastName,
                //                 p.MiddleName,
                //                 p.SuffixCode,
                //                 p.Last4SsnEinID,
                //                 ResultRecord = new ResultRecord
                //                 {
                //                     Id = p.PersonID,
                //                     Ssn = p.SsnEinID,
                //                     AgencyNum = 0,         //TODO: ?? - need to assign agency
                //                     PlanCode = null,       //TODO: ?? - need to assign plan code
                //                     LastCheckDate = null,  //TODO: ?? - need to assign last check date
                //                     IsRetired = p.RetiredMemberInd == "Y",
                //                     DateOfBirth = p.BirthDate,
                //                     GenderCode = p.GenderCode
                //                 }
                //             });

                //query = query.ConditionalWhere(criteria?.Ssn?.Length == 9, q => q.ResultRecord.Ssn == criteria.Ssn);
                //query = query.ConditionalWhere(criteria?.Ssn?.Length == 4, q => q.Last4SsnEinID == criteria.Ssn);
                //query = query.ConditionalWhere(criteria.Name, q => q.FirstName.Contains(criteria.Name) || q.LastName.Contains(criteria.Name) || q.MiddleName.Contains(criteria.Name));  //TODO: ?? enhance to support case-insensitive searching for Oracle?

                //var records = query.Take(501).ToList();
                //foreach (var record in records)
                //{
                //    record.ResultRecord.Name = StringUtil.FormatName(record.FirstName, record.MiddleName, record.LastName, record.SuffixCode);
                //}

                //return records.Select(r => r.ResultRecord).ToList();
                return(null);
            }
        }
Beispiel #19
0
        public static VoluntaryPlanWaiverRequestDto GetRequest(int RequestId)
        {
            using (DbContext context = new DbContext())
            {
                #region Commented
                //var query = (from req in context.VoluntaryPlanWaiverRequests

                //			 join frm in context.Forms
                //			 on req.FormId equals frm.FormId

                //			 join reqtyp in context.VoluntaryPlanWaiverRequestTypes
                //			 on req.VoluntaryPlanWaiverRequestId equals reqtyp.VoluntaryPlanWaiverRequestId

                //			 //join frmatt in context.FormAttachments
                //			 //on frm.FormId equals frmatt.FormId

                //			 //join doc in context.Documents
                //			 //on frmatt.DocumentId equals doc.DocumentID

                //			 where req.VoluntaryPlanWaiverRequestId == RequestId
                //			 select new VPRequestViewModel
                //			 {
                //				 RequestId = req.VoluntaryPlanWaiverRequestId,
                //				 StartDate = req.StartDate,
                //				 EndDate = req.EndDate,
                //				 TypesofLeaveAvailable = reqtyp.LeaveTypeCode,
                //				 WeeksAvailableAnnually = reqtyp.DurationInWeeksCode,
                //				 PercentageofWagesPaid = reqtyp.PercentagePaid,
                //				 DocumentName = "My Document"//doc.DocumentName

                //			 })?.ToList();
                //return query;
                #endregion
                var record = (from vpwr in context.VoluntaryPlanWaiverRequests.Include("VoluntaryPlanWaiverRequestTypes").Include("Form.FormAttachments.Document")
                              where vpwr.VoluntaryPlanWaiverRequestId == RequestId
                              select vpwr).FirstOrDefault();
                return(record.ToDtoDeep(context));
            }
        }
Beispiel #20
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);
        }
Beispiel #21
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));
        }
Beispiel #22
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);
        }