public DepreciationRate UpdateDepreciationRate(DepreciationRate depreciationRate)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                var groupNames = new List <string>()
                {
                    BudgetModuleDefinition.GROUP_ADMINISTRATOR, BudgetModuleDefinition.GROUP_BUSINESS
                };
                AllowAccessToOperation(BudgetModuleDefinition.SOLUTION_NAME, groupNames);

                IDepreciationRateRepository depreciationRateRepository = _DataRepositoryFactory.GetDataRepository <IDepreciationRateRepository>();

                DepreciationRate updatedEntity = null;

                if (depreciationRate.DepreciationRateId == 0)
                {
                    updatedEntity = depreciationRateRepository.Add(depreciationRate);
                }
                else
                {
                    updatedEntity = depreciationRateRepository.Update(depreciationRate);
                }

                return updatedEntity;
            }));
        }
Exemple #2
0
 private DepreciationRateGridRow GetDepreciationRateGridRow(DepreciationRate depreciationRate)
 {
     return(new DepreciationRateGridRow
     {
         HeadName = depreciationRate.ProjectHead.Head.Name,
         DepreciationRate = depreciationRate.Rate,
     });
 }
Exemple #3
0
        public double GetDepreciationRate(string projectName, string headName)
        {
            double      rate        = 0;
            ProjectHead projectHead = _projectHeadRepository.GetSingle(ph => ph.Head.Name == headName && ph.Project.Name == projectName);

            if (projectHead != null)
            {
                DepreciationRate depreciationRate = _depreciationRateRepository.GetSingle(dr => dr.ProjectHead != null ? (dr.ProjectHead.ID == projectHead.ID) : false);
                rate = (depreciationRate != null) ? depreciationRate.Rate : 0;
            }

            return(rate);
        }
Exemple #4
0
        public bool Set(Project project, Head head, double rate)
        {
            if (project == null)
            {
                InvokeManagerEvent(EventType.Error, "NoProjectSelected");
                return(false);
            }
            if (head == null)
            {
                InvokeManagerEvent(EventType.Error, "NoHeadSelected");
                return(false);
            }
            if (rate == 0)
            {
                // TODO: This will not work right now, think through. But not a big problem.
                InvokeManagerEvent(EventType.Warning, "ZeroDepreciationProvidedForFixedAsset");
            }

            string projectName = project.Name;
            string headName    = head.Name;

            ProjectHead projectHead = _projectHeadRepository.GetSingle(ph => ph.Head.Name == headName && ph.Project.Name == projectName);

            bool update = false;

            if (projectHead != null && projectHead.DepreciationRates != null)
            {
                DepreciationRate depreciationRate = projectHead.DepreciationRates.SingleOrDefault(b => b.IsActive);
                if (depreciationRate != null)
                {
                    depreciationRate.Rate = rate;
                    update = true;
                }
                else
                {
                    depreciationRate = new DepreciationRate
                    {
                        Rate        = rate,
                        IsActive    = true,
                        ProjectHead = projectHead
                    };
                }

                return(InsertOrUpdateNewDepreciationRate(depreciationRate, update));
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
        private bool InsertOrUpdateNewDepreciationRate(DepreciationRate depreciationRate, bool update)
        {
            if (update)
            {
                _depreciationRateRepository.Update(depreciationRate);
            }
            else
            {
                _depreciationRateRepository.Insert(depreciationRate);
            }

            if (_depreciationRateRepository.Save() > 0)
            {
                InvokeManagerEvent(new BLLEventArgs {
                    EventType = EventType.Success, MessageKey = "NewDepreciationRateSavedSuccessfully"
                });
                return(true);
            }

            InvokeManagerEvent(EventType.Error, "NewDepreciationRateInsertFailed");
            return(false);
        }
        public DepreciationRate GetDepreciationRate(int depreciationRateId)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                var groupNames = new List <string>()
                {
                    BudgetModuleDefinition.GROUP_ADMINISTRATOR, BudgetModuleDefinition.GROUP_BUSINESS
                };
                AllowAccessToOperation(BudgetModuleDefinition.SOLUTION_NAME, groupNames);

                IDepreciationRateRepository depreciationRateRepository = _DataRepositoryFactory.GetDataRepository <IDepreciationRateRepository>();

                DepreciationRate depreciationRateEntity = depreciationRateRepository.Get(depreciationRateId);
                if (depreciationRateEntity == null)
                {
                    NotFoundException ex = new NotFoundException(string.Format(" DepreciationRate with ID of {0} is not in database", depreciationRateId));
                    throw new FaultException <NotFoundException>(ex, ex.Message);
                }

                return depreciationRateEntity;
            }));
        }
 public DepreciationRate UpdateDepreciationRate(DepreciationRate depreciationRate)
 {
     return(Channel.UpdateDepreciationRate(depreciationRate));
 }