public async Task <IActionResult> Index([FromForm] IndexCard indexcard)
        {
            IIndexCard lIndexCard = indexcard;

            // howto upload files: https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-3.1#upload-small-files-with-buffered-model-binding-to-physical-storage

            // check if user is owner of the index card
            if (IndexCardBox.UserIsOwnerOfIndexCardBox(indexcard.IndexCardBoxId, base.GetCurrentUser(_context), _context) == false)
            {
                return(Forbid());
            }

            // save uploaded files
            lIndexCard = await HandleUploadedFiles(lIndexCard);

            // set date
            lIndexCard.Created  = DateTime.UtcNow;
            lIndexCard.Modified = DateTime.UtcNow;

            // save in database
            _context.IndexCards.Add((IndexCard)lIndexCard);
            await _context.SaveChangesAsync();

            // cleanup the indexcard response object
            lIndexCard = CleanupIndexCardResponse(lIndexCard);

            // return created indexcard
            return(Json(lIndexCard));
        }
        public PhoneNumber PhoneNumberGet(int x, int y)
        {
            //there might be more than 1 phone numbers with the same coordinate, we want to get the active index card coordinate
            MainWindow MainObject = (MainWindow)App.Current.MainWindow;

            if (MainObject == null)
            {
                return(null);
            }
            IndexCard ic = MainObject.GetVisibleIndexCard();

            if (ic == null)
            {
                return(null);
            }
            return(ic.PhoneNumberGet(x, y));
        }
        public async Task <IActionResult> Index(int id, [FromForm] IndexCard indexcard)
        {
            IIndexCard lIndexCard = indexcard;

            if (id != lIndexCard.Id)
            {
                return(BadRequest());
            }

            // check if user is owner of the index card
            if (UserIsOwnerOfIndexCard(lIndexCard) == false)
            {
                return(Forbid());
            }

            // check inconsistency by change date. Change-Date in PUT-Request should match the change date in the database
            // currently not working because PUT converts datetime in payload to Local time
            //var lIndexCardInDB = _context.IndexCards.SingleOrDefault(x => x.Id == id);

            //if (lIndexCardInDB == null || lIndexCardInDB.Modified != indexcard.Modified)
            //{
            //    return Conflict(); // returns an 409 conflic because of inconsistency
            //}

            // save uploaded files
            lIndexCard = await HandleUploadedFiles(lIndexCard);

            // set datelastlearned in box when user has learned the index card (Indicator: user has pushed buttons known/unknown)
            SetDateLastLearned(lIndexCard);

            // set modified date
            lIndexCard.Modified = DateTime.UtcNow;

            // set save
            _context.Entry(lIndexCard).State = EntityState.Modified;
            _context.Entry(lIndexCard).Property(x => x.Created).IsModified = false; // do not modify create date. The create date is an constant value.
            _context.SaveChanges();

            // cleanup the indexcard response object
            lIndexCard = CleanupIndexCardResponse(lIndexCard);

            return(Json(lIndexCard));
        }
        // Example URI for DELETE: todos/1
        public async Task <IActionResult> Index(int pId)
        {
            var lIndexCardBox = _context.IndexCardBoxes.Single(x => x.Id == pId);

            if (lIndexCardBox == null)
            {
                return(NotFound()); // returns an 404 page not found
            }

            IUser lUser = base.GetCurrentUser(_context);

            // check if box belongs to authenticated user
            if (IndexCardBox.UserIsOwnerOfIndexCardBox(pId, lUser, _context) == false)
            {
                return(Forbid());
            }

            // delete all index cards and uploads
            // loop all indexcards
            var lIndexCards       = _context.IndexCards.Select(x => x).Where(x => x.IndexCardBoxId == pId);
            var lIndexCardsAsList = lIndexCards.ToList <IIndexCard>();

            foreach (IIndexCard lIndexCard in lIndexCardsAsList)
            {
                // removed dependen uploaded files
                IndexCard.RemoveAllUploadedFiles(lIndexCard, _env.WebRootPath);
            }

            // remove all indexcards
            _context.IndexCards.RemoveRange(lIndexCards);
            _context.SaveChanges();

            // remove box
            _context.IndexCardBoxes.Remove(lIndexCardBox);
            _context.SaveChanges();

            return(Json(lIndexCardBox));
        }
        // Example URI for DELETE: todos/1
        public IActionResult Index(int pId)
        {
            var lIndexCard = _context.IndexCards.Single(x => x.Id == pId);

            if (lIndexCard == null)
            {
                return(NotFound()); // returns an 404 page not found
            }

            // checkk if index card belongs to user
            if (UserIsOwnerOfIndexCard(lIndexCard) == false)
            {
                return(Forbid());
            }

            // remove uploaded files
            IndexCard.RemoveAllUploadedFiles(lIndexCard, _env.WebRootPath);

            _context.Remove(lIndexCard);
            _context.SaveChanges();

            return(Json(lIndexCard));
        }
Beispiel #6
0
 public void IndexCardDelete(IndexCard ic)
 {
     IndexCards.Remove(ic);
 }
Beispiel #7
0
 public void IndexCardAdd(IndexCard ic)
 {
     ic.SetGUID(IndexCardGUID++);
     IndexCards.Add(ic);
 }
        public async Task <IActionResult> Duplicate([FromForm] IndexCard indexcard, [FromQuery] bool invertQuestionAnswer, [FromQuery] bool invertImageFiles)
        {
            // get indexcard from Server
            IIndexCard lIndexCard = _context.IndexCards.SingleOrDefault(x => x.Id == indexcard.Id);

            if (lIndexCard == null)
            {
                return(NotFound()); // returns an 404 page not found
            }

            // check if user is owner of the index card
            if (UserIsOwnerOfIndexCard(lIndexCard) == false)
            {
                return(Forbid());
            }

            // remove id to mark as a new indexcard
            lIndexCard.Id = null;

            // copy files
            if (lIndexCard.QuestionImageUrl != null)
            {
                lIndexCard.QuestionImageUrl = Upload.CopyFile(lIndexCard.QuestionImageUrl, _env.WebRootPath);
            }

            if (lIndexCard.AnswerImageUrl != null)
            {
                lIndexCard.AnswerImageUrl = Upload.CopyFile(lIndexCard.AnswerImageUrl, _env.WebRootPath);
            }

            if (lIndexCard.QuestionAudioUrl != null)
            {
                lIndexCard.QuestionAudioUrl = Upload.CopyFile(lIndexCard.QuestionAudioUrl, _env.WebRootPath);
            }

            if (lIndexCard.AnswerAudioUrl != null)
            {
                lIndexCard.AnswerAudioUrl = Upload.CopyFile(lIndexCard.AnswerAudioUrl, _env.WebRootPath);
            }

            // when user wants to invert question/answer
            if (invertQuestionAnswer)
            {
                var lAnswer   = lIndexCard.Answer;
                var lQuestion = lIndexCard.Question;

                lIndexCard.Answer   = lQuestion;
                lIndexCard.Question = lAnswer;
            }

            // when user wants to invert image files
            if (invertImageFiles)
            {
                var lQuestionImageUrl = lIndexCard.QuestionImageUrl;
                var lAnswerImageUrl   = lIndexCard.AnswerImageUrl;

                lIndexCard.QuestionImageUrl = lAnswerImageUrl;
                lIndexCard.AnswerImageUrl   = lQuestionImageUrl;
            }

            // reset the stats to 0
            lIndexCard.Known = 0;

            // update created and updated time
            lIndexCard.Created  = DateTime.UtcNow;
            lIndexCard.Modified = DateTime.UtcNow;

            // save in database
            _context.IndexCards.Add((IndexCard)lIndexCard);
            await _context.SaveChangesAsync();


            // return created indexcard
            return(Json(lIndexCard));
        }
        private void MedicalRecordManageForm_Load(object sender, EventArgs e)
        {
            tabControl.SelectedTabPage.Focus();

            //病历借阅审核界面
            MedicalRecordApprove medicalRecordApprove = new MedicalRecordApprove();

            medicalRecordApprove.Dock = DockStyle.Fill;
            //this.tabControl.TabPages[0].Controls.Add(medicalRecordApprove);
            this.tabPageApprove.Controls.Add(medicalRecordApprove);

            //病历借阅记录查询界面
            MedicalRecordApprovedList medicalRecordApprovedList = new MedicalRecordApprovedList();

            medicalRecordApprovedList.Dock = DockStyle.Fill;
            //this.tabControl.TabPages[1].Controls.Add(medicalRecordApprovedList);
            this.tabPageApprovedList.Controls.Add(medicalRecordApprovedList);
            //病历补写审核界面
            MedicalRecordWriteUpApprove medicalRecordwriteApprove = new MedicalRecordWriteUpApprove();

            medicalRecordwriteApprove.Dock = DockStyle.Fill;
            //this.tabControl.TabPages[0].Controls.Add(medicalRecordApprove);
            this.tabPageWriteUpApprove.Controls.Add(medicalRecordwriteApprove);

            //病历补写记录查询界面
            MedicalRecordWriteUpApprovedList medicalRecordWriteUpApprovedList = new MedicalRecordWriteUpApprovedList();

            medicalRecordWriteUpApprovedList.Dock = DockStyle.Fill;
            //this.tabControl.TabPages[1].Controls.Add(medicalRecordApprovedList);
            this.tabPageWriteUpApproveList.Controls.Add(medicalRecordWriteUpApprovedList);

            //病历查询界面
            MedicalRecordList medicalRecordList = new MedicalRecordList();

            medicalRecordList.Dock = DockStyle.Fill;
            //this.tabControl.TabPages[2].Controls.Add(medicalRecordList);
            this.tablePageRecord.Controls.Add(medicalRecordList);


            //病案首页编辑归档操作界面add by ywk 2013年7月30日 10:40:19
            MedIemArchive mediem = new MedIemArchive(m_app);

            mediem.Dock = DockStyle.Fill;
            this.tabTabIemAcrive.Controls.Add(mediem);

            string[] valueStr = DrectSoft.Service.DS_SqlService.GetConfigValueByKey("IsShowBinAn").Split(new char[] { '|' });
            if (valueStr.Length == 3)
            {
                if (valueStr[0] == "1")
                {
                    //未归档界面
                    MedicalRecordUnArchive userControlUn = new MedicalRecordUnArchive();
                    userControlUn.Dock = DockStyle.Fill;
                    tablePageUnRec.Controls.Add(userControlUn);
                }
                else
                {
                    this.tablePageUnRec.PageVisible = false;
                }
                if (valueStr[1] == "1")
                {
                    MedicalRecordArchive userControl = new MedicalRecordArchive();
                    userControl.Dock = DockStyle.Fill;
                    //this.tabControl.TabPages[4].Controls.Add(userControl);
                    tablePageRecChecked.Controls.Add(userControl);
                }
                else
                {
                    this.tablePageRecChecked.PageVisible = false;
                }
                if (valueStr[2] == "1")
                {
                    //索引卡
                    IndexCard indexCard = new IndexCard();
                    indexCard.Dock = DockStyle.Fill;
                    tabPageIndexCard.Controls.Add(indexCard);
                }
                else
                {
                    this.tabPageIndexCard.PageVisible = false;
                }
            }
            //配置病案首页归档可见add by ywk
            string isshowiem = DrectSoft.Service.DS_SqlService.GetConfigValueByKey("IsShowEditIemInfo");

            if (isshowiem == "0")
            {
                tabTabIemAcrive.PageVisible = false;
            }
            else
            {
                tabTabIemAcrive.PageVisible = true;
            }
            AutoFeed();
        }