Пример #1
0
        public async Task <IActionResult> Index()
        {
            var appUser = await _userManager.FindByNameAsync(User.Identity.Name);

            var userId = appUser.Id;

            TempData["userId"] = userId;
            var model = new QuotationAddViewModel();

            model.Books = GetAppUserBookSelectListItems();
            return(View(model));
        }
Пример #2
0
        public async Task <IActionResult> Index(QuotationAddViewModel model)
        {
            if (ModelState.IsValid)
            {
                var appUser = await _userManager.FindByNameAsync(User.Identity.Name);

                var userId = appUser.Id;
                model.AppUserId = userId;
                Entities.Concrete.Quotation quotation = new Entities.Concrete.Quotation
                {
                    AppUserId     = model.AppUserId,
                    QuotationText = model.QuotationText,
                    BookId        = model.BookId,
                    CurrentPage   = model.CurrentPage,
                    QuotesLike    = model.QuotesLike,
                    CreatedOn     = DateTime.Now,
                };
                _quotationService.Add(quotation);
            }

            return(RedirectToAction("Index", "Quotation"));
        }