/// <summary>
 /// Constructor converts LINQ object to Value Object
 /// </summary>
 /// <param name="milestoneBillingLine"></param>
 public MilestoneBillingLineVO(MilestoneBillingLine milestoneBillingLine)
 {
     ID           = milestoneBillingLine.ID;
     MilestoneId  = milestoneBillingLine.MilestoneID;
     ContractId   = milestoneBillingLine.ContractID;
     LineSequance = milestoneBillingLine.LineSequance.Value;
     LineText     = milestoneBillingLine.LineText;
 }
Пример #2
0
        /// <summary>
        /// Save the milestone
        /// </summary>
        /// <param name="milestoneVO">Value object of milestone</param>
        public void SaveMilestone(MilestoneVO milestoneVO)
        {
            if (milestoneVO.ID != 0)
            {
                //Update Existing Record
                Milestone selectedMilestone = mdbDataContext.Milestones.SingleOrDefault(c => c.ID == milestoneVO.ID);
                selectedMilestone.ContractID        = milestoneVO.ContractID;
                selectedMilestone.ContractLineID    = milestoneVO.ContractLineID;
                selectedMilestone.MaintenanceID     = milestoneVO.ContractMaintenanceID;
                selectedMilestone.EstimatedDate     = milestoneVO.InvoiceDate;
                selectedMilestone.RenewalStartDate  = milestoneVO.RenewalStartDate;
                selectedMilestone.RenewalEndDate    = milestoneVO.RenewalEndDate;
                selectedMilestone.Amount            = milestoneVO.Amount;
                selectedMilestone.IsApproved        = milestoneVO.IsApproved;
                selectedMilestone.MilestoneStatusID = milestoneVO.MilestoneStatusID;
                selectedMilestone.MilestoneStatus   = milestoneVO.MilestoneStatusName;
                selectedMilestone.LastUpdatedBy     = milestoneVO.LastUpdatedByUserId;
                selectedMilestone.LastUpdatedDate   = DateTime.Now;

                //ContractMaintenance maintenance = mdbDataContext.ContractMaintenances.SingleOrDefault(cm => cm.ID == milestoneVO.ContractMaintenanceID);
                //maintenance.Comment = milestoneVO.Comments;

                //Save contract maintenace lines
                foreach (var item in milestoneVO.MilestoneBillingLineVos)
                {
                    MilestoneBillingLine milestoneBillingLine =
                        selectedMilestone.MilestoneBillingLines.ToList().Find(x => x.ID == item.ID && x.ID != 0);

                    if (milestoneBillingLine != null)
                    {
                        milestoneBillingLine.LineText        = !string.IsNullOrEmpty(item.LineText) ? item.LineText.Trim() : item.LineText;
                        milestoneBillingLine.LineSequance    = item.LineSequance;
                        milestoneBillingLine.ContractID      = milestoneVO.ContractID;
                        milestoneBillingLine.MilestoneID     = milestoneVO.ID;
                        milestoneBillingLine.LastUpdatedBy   = milestoneVO.LastUpdatedByUserId;
                        milestoneBillingLine.LastUpdatedDate = DateTime.Now;
                    }
                    else
                    {
                        selectedMilestone.MilestoneBillingLines.Add(new MilestoneBillingLine()
                        {
                            LineText     = !string.IsNullOrEmpty(item.LineText) ? item.LineText.Trim() : item.LineText,
                            LineSequance = item.LineSequance,
                            ContractID   = milestoneVO.ContractID,
                            MilestoneID  = milestoneVO.ID,
                            CreatedBy    = milestoneVO.CreatedByUserId,
                            CreationDate = DateTime.Now
                        });
                    }
                }

                mdbDataContext.SubmitChanges();
            }
        }
Пример #3
0
        /// <summary>
        /// Saves Billing Line
        /// </summary>
        /// <param name="milestoneVO">MilestoneVo to save</param>
        public void SaveBillingLine(MilestoneVO milestoneVO)
        {
            if (milestoneVO != null)
            {
                ContractMaintenance maintenance = mdbDataContext.ContractMaintenances.SingleOrDefault(cm => cm.ID == milestoneVO.ContractMaintenanceID);
                //maintenance.Comment = milestoneVO.Comments;
                maintenance.Comment = !string.IsNullOrEmpty(milestoneVO.Comments) ? milestoneVO.Comments.Trim() : milestoneVO.Comments;

                //Save milestone billing details
                foreach (var item in milestoneVO.MilestoneBillingLineVos)
                {
                    MilestoneBillingLine milestoneBillingLine =
                        mdbDataContext.MilestoneBillingLines.SingleOrDefault(b => b.ID == item.ID && !b.IsDeleted);

                    if (milestoneBillingLine != null)
                    {
                        milestoneBillingLine.LineText        = !string.IsNullOrEmpty(item.LineText) ? item.LineText.Trim() : item.LineText;
                        milestoneBillingLine.LineSequance    = item.LineSequance;
                        milestoneBillingLine.ContractID      = milestoneVO.ContractID;
                        milestoneBillingLine.MilestoneID     = milestoneVO.ID;
                        milestoneBillingLine.LastUpdatedBy   = milestoneVO.LastUpdatedByUserId;
                        milestoneBillingLine.LastUpdatedDate = DateTime.Now;
                    }
                    else
                    {
                        MilestoneBillingLine newMilestoneBillingLine = new MilestoneBillingLine
                        {
                            LineText     = !string.IsNullOrEmpty(item.LineText) ? item.LineText.Trim() : item.LineText,
                            LineSequance = item.LineSequance,
                            ContractID   = milestoneVO.ContractID,
                            MilestoneID  = milestoneVO.ID,
                            CreatedBy    = milestoneVO.CreatedByUserId,
                            CreationDate = DateTime.Now
                        };
                        mdbDataContext.MilestoneBillingLines.InsertOnSubmit(newMilestoneBillingLine);
                    }
                }

                mdbDataContext.SubmitChanges();
            }
        }
Пример #4
0
        /// <summary>
        /// Save recalculated milestones
        /// </summary>
        /// <param name="milestoneVos">list of milestone vos to save</param>
        public void SaveRecalculatedMilestone(List <MilestoneVO> milestoneVos)
        {
            foreach (var milestoneVo in milestoneVos)
            {
                Milestone selectedMilestone = mdbDataContext.Milestones.SingleOrDefault(c => c.ID == milestoneVo.ID) ??
                                              new Milestone();

                selectedMilestone.ContractID        = milestoneVo.ContractID;
                selectedMilestone.ContractLineID    = milestoneVo.ContractLineID;
                selectedMilestone.MaintenanceID     = milestoneVo.ContractMaintenanceID;
                selectedMilestone.EstimatedDate     = milestoneVo.InvoiceDate;
                selectedMilestone.RenewalStartDate  = milestoneVo.RenewalStartDate;
                selectedMilestone.RenewalEndDate    = milestoneVo.RenewalEndDate;
                selectedMilestone.Amount            = Math.Round(milestoneVo.Amount, 2);
                selectedMilestone.PreviousValue     = milestoneVo.PreviousValue.Value;
                selectedMilestone.IsApproved        = milestoneVo.IsApproved;
                selectedMilestone.MilestoneStatusID = milestoneVo.MilestoneStatusID;

                selectedMilestone.Uplift           = milestoneVo.Uplift;
                selectedMilestone.UpliftFixedRate  = milestoneVo.UpliftFixedRate;
                selectedMilestone.UpliftPercentage = milestoneVo.UpliftPercentage;
                selectedMilestone.UpliftRate       = milestoneVo.UpliftRate;
                selectedMilestone.ChargingUpliftID = milestoneVo.ChargingUpliftID;
                selectedMilestone.IndexRate        = milestoneVo.IndexRate;

                selectedMilestone.IsDeleted       = milestoneVo.IsDeleted;
                selectedMilestone.LastUpdatedBy   = milestoneVo.LastUpdatedByUserId;
                selectedMilestone.LastUpdatedDate = DateTime.Now;

                //Save contract maintenace lines
                foreach (var item in milestoneVo.MilestoneBillingLineVos)
                {
                    if (item.ID != 0)
                    {
                        MilestoneBillingLine milestoneBillingLine =
                            selectedMilestone.MilestoneBillingLines.ToList().Find(x => x.ID == item.ID && !x.IsDeleted);

                        if (milestoneBillingLine != null)
                        {
                            milestoneBillingLine.LineText        = item.LineText;
                            milestoneBillingLine.LineSequance    = item.LineSequance;
                            milestoneBillingLine.ContractID      = selectedMilestone.ContractID;
                            milestoneBillingLine.MilestoneID     = selectedMilestone.ID;
                            milestoneBillingLine.IsDeleted       = item.IsDeleted;
                            milestoneBillingLine.LastUpdatedBy   = selectedMilestone.LastUpdatedBy;
                            milestoneBillingLine.LastUpdatedDate = DateTime.Now;
                        }
                    }
                    else
                    {
                        selectedMilestone.MilestoneBillingLines.Add(new MilestoneBillingLine()
                        {
                            LineText     = item.LineText,
                            LineSequance = item.LineSequance,
                            ContractID   = selectedMilestone.ContractID,
                            MilestoneID  = selectedMilestone.ID,
                            IsDeleted    = item.IsDeleted,
                            CreatedBy    = selectedMilestone.CreatedBy,
                            CreationDate = DateTime.Now
                        });
                    }
                }

                if (selectedMilestone.ID == 0)
                {
                    selectedMilestone.CreatedBy    = milestoneVo.CreatedByUserId;
                    selectedMilestone.CreationDate = DateTime.Now;

                    mdbDataContext.Milestones.InsertOnSubmit(selectedMilestone);
                }
            }
            mdbDataContext.SubmitChanges();
        }