Beispiel #1
0
        public ActionResult Edit(int?id)
        {
            ReaderRepository repository = new ReaderRepository();

            ReaderEditViewModel model = new ReaderEditViewModel();

            if (id.HasValue)
            {
                Reader readers = repository.GetById(id.Value);
                model.Id         = readers.Id;
                model.firstName  = readers.firstName;
                model.lastName   = readers.lastName;
                model.readerCard = readers.readerCard;
                model.expireDate = readers.expireDate;
            }

            return(View(model));
        }
        public ActionResult ReaderList(int?PanelID)
        {
            ReaderFill();

            if (user.SysAdmin == false)
            {
                throw new Exception("Yetkisiz Erişim!");
            }


            if (_panelSettingsService.GetAllPanelSettings(x => x.Panel_TCP_Port != 0 && x.Panel_IP1 != 0 && x.Panel_IP2 != 0 && x.Panel_IP3 != 0 && x.Panel_IP4 != 0).Count == 0)
            {
                throw new Exception("Sistemde kayıtlı panel bulunamadı");
            }
            List <ReaderSettingsNew> okuyucular = new List <ReaderSettingsNew>();

            if (PanelID == null)
            {
                PanelID    = _panelSettingsService.GetAllPanelSettings(x => x.Panel_TCP_Port != 0 && x.Panel_IP1 != 0 && x.Panel_IP2 != 0 && x.Panel_IP3 != 0 && x.Panel_IP4 != 0).OrderBy(x => x.Kayit_No).FirstOrDefault().Panel_ID;
                okuyucular = _readerSettingsNewService.GetAllReaderSettingsNew(x => x.Panel_ID == PanelID && dbDoorList.Contains(x.Kayit_No)).OrderBy(x => x.WKapi_ID).ToList();
            }
            else
            {
                okuyucular = _readerSettingsNewService.GetAllReaderSettingsNew(x => x.Panel_ID == PanelID && dbDoorList.Contains(x.Kayit_No)).OrderBy(x => x.WKapi_ID).ToList();
            }
            if (okuyucular == null)
            {
                throw new Exception("Bu panele ait okuyucu bulunmamaktadır.");
            }
            var panelModel = _panelSettingsService.GetAllPanelSettings().FirstOrDefault(x => x.Panel_ID == PanelID).Panel_Model;
            var model      = new ReaderEditViewModel
            {
                Paneller   = _panelSettingsService.GetAllPanelSettings(x => x.Panel_TCP_Port != 0 && x.Panel_IP1 != 0 && x.Panel_IP2 != 0 && x.Panel_IP3 != 0 && x.Panel_IP4 != 0), // _reportService.PanelListesi(user),
                Okuyucular = okuyucular.OrderBy(x => x.WKapi_ID).ToList(),
                Panel_ID   = PanelID,
                PanelModel = panelModel
            };



            return(View(model));
        }
Beispiel #3
0
        public ActionResult Edit(ReaderEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            ReaderRepository repository = new ReaderRepository();

            Reader readers = new Reader();

            readers.Id         = model.Id;
            readers.firstName  = model.firstName;
            readers.lastName   = model.lastName;
            readers.readerCard = model.readerCard;
            readers.expireDate = model.expireDate;

            repository.Save(readers);

            return(RedirectToAction("Index"));
        }