コード例 #1
0
        public ActionResult ReadBooksAdd(int ReaderId)
        {
            var brViewModel = new BRViewModel();

            using (var booksListContext = new BooksListContext())
            {
                var reader          = booksListContext.Readers.SingleOrDefault(p => p.ReaderId == ReaderId);
                var readerViewModel = new ReaderViewModel()
                {
                    ReaderId = ReaderId,
                    Name     = reader.Name,
                };

                brViewModel.Readers = readerViewModel;
                var booksRead = booksListContext.BooksRead.Where(p => p.ReaderId == ReaderId).ToList();
                var allbooks  = booksListContext.Books.ToList();
                var Result    = allbooks.Where(item => !booksRead.Any(item2 => item2.BookId == item.BookId));

                ViewBag.BooksRead = Result.Select(c => new SelectListItem

                {
                    Value = c.BookId.ToString(),
                    Text  = c.Title
                }).ToList();
            }



            return(View("AddEditBooksRead", brViewModel));
        }
コード例 #2
0
        public async Task<ActionResult> ReaderLogin(ReaderViewModel reader)
        {
            if (ModelState.IsValid)
            {
                using (MounbDbContext _db = new MounbDbContext())
                {
                    // поиск Читателя
                    int readerId = await (from r in _db.Readers
                                    .Where(r => r.LibraryCardId.Value == reader.LibraryCardId
                                    && r.DOB.Day == reader.DOB.Day
                                    && r.DOB.Month == reader.DOB.Month
                                    && r.DOB.Year == reader.DOB.Year)
                                          select r.Id).FirstOrDefaultAsync();

                    if (readerId != 0)
                    {
                        FormsAuthentication.SetAuthCookie(reader.LibraryCardId.ToString(), true);
                        ViewBag.readerId = readerId;
                        return PartialView("Success");
                    }
                    else
                    {

                        ModelState.AddModelError("", "Пользователь не найден");
                    }
                }
            }
            return View(reader);
        } // Конец метода
コード例 #3
0
        public EditReaderView()
        {
            InitializeComponent();
            ReaderViewModel readerViewModel = (ReaderViewModel)DataContext;

            readerViewModel.MessageBoxShowDelegate = text => MessageBox.Show(text, "Information", MessageBoxButton.OK, MessageBoxImage.Information);
        }
コード例 #4
0
        public ActionResult Index(ReaderViewModel model)
        {
            model.CountryOptions     = defaultListItem;
            model.StateOptions       = defaultListItem;
            model.CityOptions        = defaultListItem;
            model.CategoryOptions    = defaultListItem;
            model.SubCategoryOptions = defaultListItem;

            EditorRepository repo = new EditorRepository();

            repo.AddAssistData(model);

            CategoryRepository catRepo    = new CategoryRepository();
            ReaderRepository   repoReader = new ReaderRepository();

            //CategoryRepository catRepo = new CategoryRepository();
            //ReaderViewModel models = new ReaderViewModel();
            model.CountryOptions     = repoReader.GetCountry();
            model.CategoryOptions    = catRepo.GetCategory();
            model.SubCategoryOptions = catRepo.GetSubCategory();

            model.save = true;
            model.information[0].Description = "";
            return(View(model));
        }
コード例 #5
0
ファイル: ViewModelTest.cs プロジェクト: apekasiewicz/PT
        public void AddReaderPopUpWasShownTest()
        {
            ReaderViewModel     vm  = new ReaderViewModel();
            ReaderListViewModel _vm = new ReaderListViewModel();

            int _boxShowCount = 0;

            vm.MessageBoxShowDelegate = (messageBoxText) =>
            {
                _boxShowCount++;
                Assert.AreEqual("Reader Added", messageBoxText);
            };
            vm.ActionText = "Reader Added";
            vm.FName      = "Test";
            vm.LName      = "Test";

            Assert.IsTrue(vm.AddReaderCommand.CanExecute(null));
            Assert.IsTrue(_vm.RefreshReadersCommand.CanExecute(null));
            Assert.IsTrue(_vm.DeleteReaderCommand.CanExecute(null));

            vm.AddReaderCommand.Execute(null);
            Assert.AreEqual(1, _boxShowCount);

            _vm.RefreshReadersCommand.Execute(null);

            Thread.Sleep(3000);
            Assert.IsTrue(_vm.Readers.Count() > 5);

            _vm.CurrentReader = _vm.Readers.LastOrDefault();
            Assert.IsNotNull(_vm.CurrentReader);

            _vm.DeleteReaderCommand.Execute(null);
        }
コード例 #6
0
        public IHttpActionResult UpdateReader(ReaderViewModel itemViewModel)
        {
            var item = Mapper.Map <Reader>(itemViewModel);

            readerBL.UpdateReader(item);

            return(Ok());
        }
コード例 #7
0
        public ActionResult Index(ReaderViewModel model)
        {
            // Call service and insert records
            var repo = new EditorRepository();

            repo.CreateInfo(model);
            return(View(model));
        }
コード例 #8
0
        public ReaderViewModel AddReader(ReaderViewModel readerRequest)
        {
            var reader = _mapper.Map <Reader>(readerRequest);

            var addedReader = _readerRepository.Add(reader);

            return(_mapper.Map <ReaderViewModel>(addedReader));
        }
コード例 #9
0
ファイル: HomeController.cs プロジェクト: miki-riglos/Reader
        public async Task <ActionResult> Index()
        {
            var subscriptions = await readerDataService.GetSubscriptionsAsync(User.Identity.Name);

            var readerViewModel = new ReaderViewModel(subscriptions);

            return(View(readerViewModel));
        }
コード例 #10
0
ファイル: ReaderController.cs プロジェクト: JBeni/TSP.NET
        public IActionResult AfisareCititori()
        {
            var readers = new ReaderViewModel
            {
                CITITORs = repository.GetAllReadersAsync().Result.ToList()
            };

            return(View(readers));
        }
コード例 #11
0
        public ActionResult <ReaderViewModel> Update([FromBody] ReaderViewModel reader)
        {
            var currentReader = userService.GetCurrentUser()?.Reader;

            repoReader.Update(mapper.Map <ReaderViewModel, Reader>(reader, currentReader));

            return(mapper
                   .Map <Reader, ReaderViewModel>(currentReader));
        }
コード例 #12
0
        public IActionResult TakeABook()
        {
            var readerViewModel = new ReaderViewModel()
            {
                Readers = _readerService.GetAllReaders(),
                Records = _readerService.GetAllRecords(),
                Books   = _readerService.GetAllBooks()
            };

            return(View("TakeABook", readerViewModel));
        }
コード例 #13
0
ファイル: MainViewModel.cs プロジェクト: Sm1rfa/ChitankaInfo
        public MainViewModel()
        {
            this.BookViewModel   = new BookViewModel();
            this.TextViewModel   = new TextViewModel();
            this.PersonViewModel = new PersonViewModel();
            this.SerieViewModel  = new SerieViewModel();
            this.SearchViewModel = new SearchViewModel();
            this.ReaderViewModel = new ReaderViewModel();

            this.AboutCommand = new RelayCommand(this.OnAboutExecuted);
        }
コード例 #14
0
        public void TestCreateReaderWithParametres()
        {
            int             count = rlvm.Users.Count();
            ReaderViewModel rvm   = new ReaderViewModel(300, "Eliza", "Lech");

            rvm.AddUser();

            Assert.AreEqual(count, rlvm.Users.Count());
            Assert.AreEqual(300, rvm.ID1);
            Assert.AreEqual("Eliza", rvm.name1);
        }
コード例 #15
0
        public void CreateInfo(ReaderViewModel model)
        {
            HttpClient client = new HttpClient();
            Dictionary <string, string> output = null;

            client.BaseAddress = new Uri(BaseAddress + "/api/Create");
            using (client)
            {
                var response = client.PostAsJsonAsync <ReaderViewModel>("", model);
                var resilt   = response.Result;
            }
        }
コード例 #16
0
ファイル: LogService.cs プロジェクト: andrigel/CSharpEntity
        public LogViewModel LogDBModelToViewById(int logId)
        {
            var _log = _dataManager.Logs.GetLogById(logId, true);

            ReaderViewModel _reader = _readerService.ReaderDBModelToViewModelById(_log.Reader.Id);
            BookViewModel   _book   = _bookService.BookDBToViewModelById(_log.Book.Id);

            return(new LogViewModel()
            {
                Log = _log, Reader = _reader, Book = _book
            });
        }
コード例 #17
0
        public void TestCreateReader()
        {
            int             count = rlvm.Users.Count();
            ReaderViewModel rvm   = new ReaderViewModel();

            rvm.name1    = "Lidia";
            rvm.surname1 = "Opala";
            rvm.AddUser();

            Assert.IsNotNull(rlvm.Users);
            Assert.AreEqual(count, rlvm.Users.Count());
        }
コード例 #18
0
        public void TestEditUser()
        {
            int             count = rlvm.Users.Count();
            ReaderViewModel rvm   = new ReaderViewModel(301, "Chelena", "Kórcewiczuwna");

            rvm.AddUser();
            rvm.name1    = "Helena";
            rvm.surname1 = "Kurcewiczówna";
            rvm.EditUser();

            Assert.AreEqual("Helena", rvm.name1);
        }
コード例 #19
0
        public async Task <IActionResult> Login(ReaderViewModel reader)
        {
            _http.BaseAddress = new Uri(apiUrl + "Reader/ReaderLogin");
            var postTask = await _http.PostAsJsonAsync <ReaderViewModel>("ReaderLogin", reader);

            ViewBag.message = postTask.StatusCode;
            if (postTask.IsSuccessStatusCode)
            {
                return(RedirectToAction("ReaderArticles")); // Looks like it will use the actual method name if it can't find the method with the desired path
            }
            ViewBag.type = "Reader";
            return(View("ErrorLogin"));
        }
コード例 #20
0
        public IActionResult TakeABook(string readerId, string bookId)
        {
            _readerService.AddBookToReader(int.Parse(readerId), int.Parse(bookId));

            var readerViewModel = new ReaderViewModel()
            {
                Readers = _readerService.GetAllReaders(),
                Records = _readerService.GetAllRecords(),
                Books   = _readerService.GetAllBooks()
            };

            return(View("TakeABook", readerViewModel));
        }
コード例 #21
0
        public IActionResult AddOrEdit(ReaderViewModel readerViewModel)
        {
            if (readerViewModel.Id == Guid.Empty)
            {
                _readerService.AddReader(readerViewModel);
            }
            else
            {
                _readerService.EditReader(readerViewModel);
            }

            return(RedirectToAction("Index"));
        }
コード例 #22
0
        //call API
        public void AddAssistData(ReaderViewModel model)
        {
            //call API
            HttpClient client = new HttpClient();
            Dictionary <string, string> output = null;

            //client.BaseAddress = new Uri(BaseAddress + "/api/Insert?Country=" + model.Country + "&State=" + model.State + "&City=" + model.City + "&Category=" + model.Category + "&SubCategory=" + model.SubCategory + "&Description=" + model.information[0].Description + "&Likes=" + model.information[0].Id + "&PostDate=" + model.information[0].PostDate);
            client.BaseAddress = new Uri(BaseAddress + "/api/Create");
            using (client)
            {
                var response = client.PostAsJsonAsync <ReaderViewModel>("", model);
                var resilt   = response.Result;
            }
        }
コード例 #23
0
        public ActionResult Index(ReaderViewModel model)
        {
            var repoReader             = new ReaderRepository();
            CategoryRepository catRepo = new CategoryRepository();

            model.CountryOptions     = repoReader.GetCountry();
            model.StateOptions       = (!string.IsNullOrWhiteSpace(model.Country)) ? repoReader.GetStates(model.Country) : defaultListItem;
            model.CityOptions        = (!string.IsNullOrWhiteSpace(model.State)) ? repoReader.GetCity(model.State) : defaultListItem;
            model.CategoryOptions    = catRepo.GetCategory();
            model.SubCategoryOptions = defaultListItem;
            model.information        = repoReader.GetRecords(model);

            return(View(model));
        }
コード例 #24
0
        // GET: Reader
        public ActionResult Index()
        {
            ReaderRepository   repo    = new ReaderRepository();
            CategoryRepository catRepo = new CategoryRepository();
            ReaderViewModel    model   = new ReaderViewModel();

            model.CountryOptions     = repo.GetCountry();
            model.StateOptions       = defaultListItem;
            model.CityOptions        = defaultListItem;
            model.CategoryOptions    = catRepo.GetCategory();
            model.SubCategoryOptions = catRepo.GetSubCategory();

            return(View(model));
        }
コード例 #25
0
        // GET: Search
        public ActionResult Index()
        {
            var repo = new GeoRepository();

            var model = new ReaderViewModel()
            {
                CountryOptions     = repo.GetCountries(),
                StateOptions       = defaultListItem,
                CityOptions        = defaultListItem,
                CategoryOptions    = repo.GetCategory(),
                SubCategoryOptions = defaultListItem
            };

            return(View(model));
        }
コード例 #26
0
        public List <Information> GetRecords(ReaderViewModel readerViewModel)
        {
            HttpClient client = new HttpClient();

            List <Information> output = new List <Information>();

            client.BaseAddress = new Uri(BaseAddress + "/api/Read?Country=" + readerViewModel.Country + "&State=" + readerViewModel.State + "&City=" + readerViewModel.City + "&Category=" + readerViewModel.Category + "&SubCategory=" + readerViewModel.SubCategory);
            using (client)
            {
                var response = client.GetAsync("").Result;
                output = response.Content.ReadAsAsync <List <Information> >().Result;
            }

            return(output);
        }
コード例 #27
0
        public IActionResult Confirm(ReaderViewModel model)
        {
            _http.BaseAddress = new Uri(apiUrl + "Reader/CreateReader");
            var postTask = _http.PostAsJsonAsync <ReaderViewModel>("CreateReader", model);

            postTask.Wait();
            var result = postTask.Result;

            ViewBag.message = result.StatusCode;
            if (result.IsSuccessStatusCode)
            {
                return(RedirectToAction("get"));
            }
            ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
            return(View("signup"));
        }
コード例 #28
0
        public void TestAddEvent()
        {
            BookViewModel bvm = new BookViewModel(200, "Ogniem i mieczem", "Henryk Sienkiewicz", "KWE", 1884);

            bvm.AddBook();
            ReaderViewModel rvm = new ReaderViewModel(2137, "Jan", "Pawłowski");

            rvm.AddUser();
            EventViewModel evm = new EventViewModel();

            evm.book1   = 200;
            evm.reader1 = 2137;

            Assert.AreEqual(200, evm.book1);
            Assert.AreEqual(2137, evm.reader1);
        }
コード例 #29
0
ファイル: ViewModelTest.cs プロジェクト: apekasiewicz/PT
        public void CreatorTestMethodAddEditView()
        {
            ReaderViewModel vm = new ReaderViewModel();

            Assert.IsNull(vm.FName);
            Assert.IsNull(vm.LName);
            Assert.IsNull(vm.Id);
            Assert.IsTrue(String.IsNullOrEmpty(vm.ActionText));
            Assert.IsNotNull(vm.MessageBoxShowDelegate);

            Assert.IsNotNull(vm.AddReaderCommand);
            Assert.IsNotNull(vm.EditReaderCommand);

            Assert.IsTrue(vm.AddReaderCommand.CanExecute(null));
            Assert.IsTrue(vm.EditReaderCommand.CanExecute(null));
        }
コード例 #30
0
        public void Read <T>(Chapter chapter) where T : System.Windows.Controls.Page
        {
            var readerModel = new ReaderViewModel {
                Hq                 = _detailsViewModel.Hq,
                ActualChapter      = chapter,
                ActualChapterIndex = _detailsViewModel.Hq.Chapters.IndexOf(chapter)
            };
            var next = readerModel.ActualChapterIndex + 1;

            if (next < readerModel.Hq.Chapters.Count)
            {
                readerModel.NextChapter = readerModel.Hq.Chapters[next];
            }
            if (readerModel.ActualChapterIndex > 0)
            {
                readerModel.PreviousChapter = readerModel.Hq.Chapters[readerModel.ActualChapterIndex - 1];
            }

            _navigationManager.Navigate <T>("Reader", readerModel);
        }