Beispiel #1
0
        /// <summary>
        /// Removes a quotation from a customer
        /// </summary>
        /// <param name="quotation">Quotation to be removed</param>
        public void RemoveQuotation(Quotation quotation)
        {
            int index = CustomerModel.GetQuotationIndexByID(quotation);

            // If the quotation exists, remove it from the collection. Otherwise throw exception.
            if (index != -1)
            {
                Quotations.RemoveAt(index);
                CustomerModel.Quotations.Remove(quotation);
            }
            else
            {
                throw new InvalidOperationException("Quotation not found");
            }
        }
Beispiel #2
0
        public void AddQuotation(Quotation quotation)
        {
            int index = CustomerModel.GetQuotationIndexByID(quotation);

            // If the quotation does not exist, add it to the quotation collection. Otherwise throw exception.
            if (index == -1)
            {
                quotation.Customer = CustomerModel;

                QuotationViewModel quotationViewModel = new QuotationViewModel(quotation);
                quotationViewModel.Customer = this;

                Quotations.Add(quotationViewModel);
                CustomerModel.Quotations.Add(quotation);
            }
            else
            {
                throw new InvalidOperationException("Cannot add already existing quotation");
            }
        }