Beispiel #1
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    TinyLibraryServiceClient svcClient = new TinyLibraryServiceClient();
                    bool ret = svcClient.AddReader(new ReaderData
                    {
                        Id       = Guid.NewGuid(),
                        Name     = model.Name,
                        UserName = model.UserName
                    });
                    svcClient.Close();
                    if (ret)
                    {
                        FormsService.SignIn(model.UserName, false /* createPersistentCookie */);
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                    }
                }
                else
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                }
            }
            // If we got this far, something failed, redisplay form
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
            return(View(model));
        }
        public ActionResult BookReturn(Guid id)
        {
            TinyLibraryServiceClient svcClient = new TinyLibraryServiceClient();

            svcClient.Return(User.Identity.Name, id);
            svcClient.Close();
            return(View());
        }
        public ActionResult MyBooks()
        {
            TinyLibraryServiceClient svcClient = new TinyLibraryServiceClient();
            var registrationData = svcClient.GetReaderRegistrations(User.Identity.Name);

            svcClient.Close();
            return(View(registrationData));
        }
        public ActionResult BookDetails(Guid id)
        {
            TinyLibraryServiceClient svcClient = new TinyLibraryServiceClient();
            BookData bd = svcClient.GetBookDetail(id);

            svcClient.Close();
            return(View(bd));
        }
        public ActionResult Index()
        {
            TinyLibraryServiceClient svcClient = new TinyLibraryServiceClient();
            var allBooks = svcClient.GetAllBooks();

            svcClient.Close();
            return(View("Index", allBooks));
        }
        public ActionResult AddBook(BookData bookData)
        {
            TinyLibraryServiceClient svcClient = new TinyLibraryServiceClient();

            bookData.Lent = false;
            bookData.Id   = Guid.NewGuid();
            svcClient.AddBook(bookData);
            svcClient.Close();
            return(RedirectToAction("Index"));
        }