Beispiel #1
0
        public TimeSpend ChangePaymentStatus(TimeSpend timeSpend, PaymentStatus newStatus)
        {
            if (!ProjectSecurity.CanEditPaymentStatus(timeSpend))
            {
                throw new SecurityException("Access denied.");
            }

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

            var task = taskDao.GetById(timeSpend.Task.ID);

            if (task == null)
            {
                throw new Exception("Task can't be null.");
            }

            ProjectSecurity.DemandEdit(timeSpend);

            if (timeSpend.PaymentStatus == newStatus)
            {
                return(timeSpend);
            }

            timeSpend.PaymentStatus = newStatus;

            return(timeSpendDao.Save(timeSpend));
        }