Beispiel #1
0
        public IActionResult Add(BookFormDto bookFormDto)
        {
            if (ModelState.IsValid)
            {
                bookPilotageService.AddOrUpdateBook(bookFormDto);

                return(Ok());
            }

            return(GetBookFormBody(bookFormDto));
        }
Beispiel #2
0
        private JsonResult GetBookFormBody(BookFormDto bookFormDto)
        {
            var bookFormReferenceDto = bookPilotageService.GetBookFormReferenceDto();

            ViewBag.Authors = bookFormReferenceDto.Authors;

            var html = PartialView("views/pilotage/books/_Modal_Book_Body.cshtml", bookFormDto).Render(this.HttpContext);

            Response.StatusCode = ModelState.IsValid ? (int)HttpStatusCode.OK : (int)HttpStatusCode.BadRequest;
            return(Json(html));
        }
Beispiel #3
0
        private JsonResult GetBookFormBody(BookFormDto bookFormDto)
        {
            var bookFormReferenceDto = bookPilotageService.GetBookFormReferenceDto();

            ViewBag.Authors = bookFormReferenceDto.Authors;

            var view         = ViewRenderer.RenderPartialView("_Modal_Book_Body", bookFormDto, this.ControllerContext);
            var jsonResponse = new JsonResponse(this.ModelState.IsValid, null, view);

            return(Json(jsonResponse, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public JsonResult Edit(int bookId, BookFormDto bookFormDto)
        {
            if (ModelState.IsValid)
            {
                bookPilotageService.AddOrUpdateBook(bookFormDto, bookId);

                var bookIndexDto = bookPilotageService.GetBookIndexDto(bookId);
                var html         = PartialView("views/pilotage/books/_Index_Book.cshtml", bookIndexDto).Render(this.HttpContext);
                var data         = new
                {
                    BookId = bookId,
                    Html   = html
                };

                return(Json(data));
            }

            return(GetBookFormBody(bookFormDto));
        }
Beispiel #5
0
        public JsonResult Edit(int bookId, BookFormDto bookFormDto)
        {
            if (ModelState.IsValid)
            {
                bookPilotageService.AddOrUpdateBook(bookFormDto, bookId);

                var bookIndexDto = bookPilotageService.GetBookIndexDto(bookId);
                var html         = ViewRenderer.RenderPartialView("_Index_Book", bookIndexDto, this.ControllerContext);
                var data         = new
                {
                    BookId = bookId,
                    Html   = html
                };

                var jsonResponse = new JsonResponse(data);

                return(Json(jsonResponse, JsonRequestBehavior.AllowGet));
            }

            return(GetBookFormBody(bookFormDto));
        }
Beispiel #6
0
        public IActionResult Add()
        {
            var bookFormDto = new BookFormDto();

            return(GetBookFormBody(bookFormDto));
        }