Example #1
0
        public ActionResult Create([Bind(Include = "Address,LibraryId,PostCode,Name,Capacity,Phone,OpenHours")] Library library)
        {
            if (ModelState.IsValid)
            {
                _libraryService.CreateLibrary(library);
                return(RedirectToAction("Index"));
            }

            return(View(library));
        }
Example #2
0
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                if (Library.Id == 0)
                {
                    Library = libraryService.CreateLibrary(Library);
                }
                else
                {
                    Library = libraryService.UpdateLibrary(Library);
                }

                libraryService.Commit();

                return(RedirectToPage("LibrariesList", new { id = Library.Id }));
            }

            return(Page());
        }
        public IActionResult Edit(Library library)
        {
            if (ModelState.IsValid)
            {
                if (library.Id == 0)
                {
                    library             = libraryService.CreateLibrary(library);
                    TempData["Message"] = "Library Created!";
                }
                else
                {
                    library             = libraryService.UpdateLibrary(library);
                    TempData["Message"] = "Library Editted!";
                }
                libraryService.Commit();

                return(RedirectToAction("Details", new { id = library.Id }));
            }

            return(View(library));
        }