Example #1
0
        /// <summary>
        /// Handles the specified <see cref="NotifyTimeRecord"/>command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <exception cref="System.ArgumentNullException">When TimeRecordId is null.</exception>
        public void Handle(NotifyTimeRecord command)
        {
            if (command.Id == null)
            {
                throw new ArgumentNullException("TimeRecordId", "TimeRecordId must be specified.");
            }

            var timeRecord = this.timeRecordRepository.Get(command.Id);

            timeRecord.NotifyTimeRecord();

            this.timeRecordRepository.Save(timeRecord);
        }
Example #2
0
        public ActionResult Notify([Bind(Prefix = "NotifiedTimeRecordViewModel")] IEnumerable <NotifiedTimeRecordViewModel> models)
        {
            if (models == null)
            {
                return(RedirectToAction("Index"));
            }

            models = models.Where(x => x.IsNotified);

            foreach (var notifiedTimeRecord in models)
            {
                var command = new NotifyTimeRecord(new TimeRecordId(notifiedTimeRecord.TimeRecordId));
                _commandSender.Send(command);
            }
            return(RedirectToAction("Index"));
        }