public void UpdateOrphanDocument(int documentId, Visit visit, string chartId, DocumentType type, string docDescription)
 {
     var document = _documentRepository.GetDocumentById(documentId);
     document.ChartId = chartId;
     document.Visit = visit;
     document.DocumentType = type;
     document.DocumentDate = Convert.ToDateTime(visit.Date);
     document.Description = docDescription;
     var updatedDocument = MoveFile(document);
     _refreshDocumentRepository.SaveDocument(updatedDocument);
 }
        protected void UpdateOrphanDocument(object sender, EventArgs e)
        {
            if (ddlDocType.SelectedIndex == 0 || tbpatientid.Text == "")
            {
                lblError.Text = "You must fill in all the required fields.";
                notificationerror.Attributes.CssStyle.Add(HtmlTextWriterStyle.Display, "block");
                return;
            }

            var visit = new Visit{Date = ddlVisitDate.SelectedItem.Text,VisitId = Convert.ToInt32(ddlVisitDate.SelectedValue)};
            var type = new DocumentType {Type = ddlDocType.SelectedItem.Text, TypeId = Convert.ToInt32(ddlDocType.SelectedValue)};
            try
            {
                _qcService.UpdateOrphanDocument(Convert.ToInt32(_documentId), visit, ddlChartId.SelectedItem.Text, type, tbDocDescription.Text);

            }
            catch (Exception ex)
            {
                lblError.Text = "An error occured, please contact an administrator.  Error: " + ex.Message;
                notificationerror.Attributes.CssStyle.Add(HtmlTextWriterStyle.Display, "block");
                return;
            }

            if (sender == bupdate)
            {
                Response.Redirect("Default.aspx?success=true");
            }
            else
            {
                UpdateOrphanDocumentAndGoToNext(sender, e);
            }
        }