Exemple #1
0
        /// <summary>
        /// Udførelse af kommandoen.
        /// </summary>
        /// <param name="command">Command til opdatering af en given gruppe til budgetkonti.</param>
        /// <returns>Opdateret gruppe til budgetkonti.</returns>
        public BudgetkontogruppeView Execute(BudgetkontogruppeModifyCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            Budgetkontogruppe budgetkontogruppe;

            try
            {
                budgetkontogruppe = _finansstyringRepository.BudgetkontogrupperGetAll()
                                    .Single(m => m.Nummer == command.Nummer);
            }
            catch (InvalidOperationException ex)
            {
                throw new DataAccessSystemException(
                          Resource.GetExceptionMessage(ExceptionMessage.CantFindUniqueRecordId, typeof(Budgetkontogruppe),
                                                       command.Nummer), ex);
            }
            budgetkontogruppe.SætNavn(command.Navn);

            var opdateretBudgetkontogruppe = _finansstyringRepository.BudgetkontogruppeModify(budgetkontogruppe.Nummer,
                                                                                              budgetkontogruppe.Navn);

            return(_objectMapper.Map <Budgetkontogruppe, BudgetkontogruppeView>(opdateretBudgetkontogruppe));
        }