Example #1
0
        public void UpdateOffer(OfferDto offerDto)
        {
            offerDto.ClientID = GetClientID(offerDto);

            Offer offer = _offerRepository.Find(offerDto.ID);

            _offerRepository.Update(Mapper.Map(offerDto, offer));

            //TODO: stored procedure that will take xml and process offer
            foreach (OfferNoteDto noteDto in offerDto.OfferNotes)
            {
                OfferNote note = _offerNoteRepository.Find(noteDto.ID.Value);
                _offerNoteRepository.Update(Mapper.Map(noteDto, note));
            }

            foreach (OfferSectionDto sectionDto in offerDto.OfferSections)
            {
                OfferSection section = _offerSectionRepository.Find(sectionDto.ID.Value);
                _offerSectionRepository.Update(Mapper.Map(sectionDto, section));

                foreach (OfferItemDto itemDto in sectionDto.OfferItems)
                {
                    OfferItem item = _offerItemRepository.Find(itemDto.ID.Value);
                    _offerItemRepository.Add(Mapper.Map(itemDto, item));
                }
            }
        }
Example #2
0
        public OfferDto AddOffer(OfferDto offerDto)
        {
            offerDto.ClientID = GetClientID(offerDto);

            Offer offer = Mapper.Map <OfferDto, Offer>(offerDto);

            offer = _offerRepository.Add(offer);

            //TODO: stored procedure that will take xml and process offer
            foreach (OfferNoteDto noteDto in offerDto.OfferNotes)
            {
                noteDto.OfferID = offer.ID;

                OfferNote note = Mapper.Map <OfferNoteDto, OfferNote>(noteDto);
                _offerNoteRepository.Add(note);
            }

            foreach (OfferSectionDto sectionDto in offerDto.OfferSections)
            {
                sectionDto.OfferID = offer.ID;

                OfferSection section = Mapper.Map <OfferSectionDto, OfferSection>(sectionDto);
                section = _offerSectionRepository.Add(section);

                foreach (OfferItemDto itemDto in sectionDto.OfferItems)
                {
                    itemDto.OfferSectionID = section.ID;

                    OfferItem item = Mapper.Map <OfferItemDto, OfferItem>(itemDto);
                    _offerItemRepository.Add(item);
                }
            }

            return(Mapper.Map <Offer, OfferDto>(offer));
        }