Пример #1
0
        public Quote Create(Guid id, Guid customerId, string orderNumber, string adviceNumber, Guid currencyId)
        {
            if (!CurrentUser.HasRole(UserRole.Manager))
            {
                throw new DomainValidationException(Messages.InsufficientSecurityClearance);
            }
            if (id == Guid.Empty)
            {
                throw new ArgumentException("An ID must be supplied for the quote");
            }
            var quote = new Quote();

            quote.Id           = id;
            quote.QuoteNumber  = _entityIdProvider.GetIdFor <Quote>();
            quote.Customer     = GetCustomer(customerId);
            quote.CreatedBy    = CurrentUser;
            quote.DateCreated  = AppDateTime.GetUtcNow();
            quote.OrderNumber  = orderNumber;
            quote.AdviceNumber = adviceNumber;
            quote.Currency     = GetCurrency(currencyId);
            quote.IsActive     = true;
            quote.Revision     = 1;
            ValidateAnnotatedObjectThrowOnFailure(quote);
            _quoteRepository.Create(quote);
            return(quote);
        }
Пример #2
0
        public async Task <Quote> CreateQuote(Quote quote)
        {
            var author = await _authorService.GetOrCreate(quote.Author);

            var language = await _languageService.Detect(quote.Text);

            return(await _quoteRepository.Create(quote, author, language));
        }
Пример #3
0
        public ActionResult Create(Quote quote)
        {
            if (ModelState.IsValid)
            {
                if (_quoteRepository.Create(quote))
                {
                    return(RedirectToAction("Index"));
                }
            }

            return(View());
        }
Пример #4
0
 public Guid Post(Quote quote)
 {
     return(_quoteRepository.Create(quote));
 }