Пример #1
0
        public async Task <IActionResult> Bookmark([FromBody] CreateBookmarkModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(GetModelErrors(ModelState)));
            }

            try
            {
                var result = await renderer.RenderAsync(QrCodeType.Bookmark, model);

                if (result == null)
                {
                    throw new Exception(StandardErrorMessages.Requests.UnableToRenderQrCode);
                }

                return(await HandleAsync(result, QrCodeType.Bookmark, model));
            }
            catch (Exception e)
            {
                Log.Error(e.Message);

                return(StatusCode(500));
            }
        }
Пример #2
0
        public ActionResult Create()
        {
            var categories = this.Data.Categories.All()
                .Select(c =>
                    new SelectListItem()
                    {
                        Text = c.Name
                    });
            var createBookmarkModel = new CreateBookmarkModel();

            createBookmarkModel.BookmarkBindingModel = new BookmarkBindingModel();
            createBookmarkModel.Categories = categories;

            return this.View(createBookmarkModel);
        }
Пример #3
0
        public async Task <IActionResult> CreateBookmark([FromBody] CreateBookmarkModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            var bookmark = new Bookmark
            {
                PostID = model.PostID,
                UserID = model.UserID
            };

            var result = await _BookmarkRepository.Add(bookmark);

            return(Json(Ok(result)));
        }
Пример #4
0
        public ActionResult Create(CreateBookmarkModel model)
        {
            var category = this.Data.Categories.All()
                .FirstOrDefault(c => c.Name == model.BookmarkBindingModel.Category);
            string userId = this.User.Identity.GetUserId();

            this.Data.Bookmarks.Add(new Bookmark()
            {
                Title = model.BookmarkBindingModel.Title,
                URL = model.BookmarkBindingModel.URL,
                Description = model.BookmarkBindingModel.Description,
                CategoryId = category.Id,
                UserId = userId
            });
            this.Data.SaveChanges();           

            return this.RedirectToAction("Index", "Home");
        }
Пример #5
0
        private async Task <QRCodeData> GenerateBookmarkQrCode(CreateBookmarkModel model)
        {
            var bookmark = new Bookmark(model.Url, model.Title);

            return(await GenerateAsync(bookmark));
        }