Ejemplo n.º 1
0
        public BrowseController(IStructureRepository structureRepository, 
		                         IDocumentRepository documentRepository)
            : base(false)
        {
            _structureRepository = structureRepository;
            _documentRepository = documentRepository;

            _document = new Document(_documentRepository);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int structureId)
        {
            Structure structure = _structureRepository.LoadStructure(structureId);

            _document = _document.Load(structure.StructureID);

            ViewData["Document"] = (_document ?? new Document{});
            Status status = Status.Review;
            ViewData["Status"] = Enum.GetName(typeof(Status), status);
            ViewData["StatusList"] = new List<string>(new string [] { "Review", "Live" });
            return View(structure);
        }
Ejemplo n.º 3
0
        public Document AddDocument(Document document)
        {
            document.Created = DateTime.Now;
            _db.Document.InsertOnSubmit(document);
            _db.SubmitChanges();

            // update root id to be the same as doc id
            if (document.DocumentRootID == null)
            {
                document.DocumentRootID = document.DocumentID;
                this.UpdateDocument(document);
            }

            return document;
        }
Ejemplo n.º 4
0
        public ActionResult Edit(int structureId, string documentData, string documentName)
        {
            // update or create document
            // get review doc
            _document = _documentRepository.LoadDocumentByStructure(structureId, _document.StatusToString(Status.Review));

            // no review doc so get live
            if (_document == null)
                _document = _documentRepository.LoadDocumentByStructure(structureId);

            if (_document == null)
            {
                // no live or review doc, create a new one
                _document = new Document {
                    DocumentData = documentData,
                    DocumentName = documentName,
                    Status = Status.Review};
                _document = _document.Add(_document);
            }
            else
            {
                Document newDocument = new Document {
                    DocumentID = null,
                    DocumentRootID = _document.DocumentRootID,
                    DocumentData = documentData,
                    DocumentName = documentName,
                    Status = Status.Review };

                _document = _document.Update(newDocument);
            }

            // update structure
            Structure structure = _structureRepository.LoadStructure(structureId);
            structure.StructureDocumentID = _document.DocumentRootID;
            _structureRepository.UpdateStructure(structure);

            return RedirectToAction("Index", new { StructureID = structureId });
        }
Ejemplo n.º 5
0
 public ActionResult Reject(int documentId)
 {
     _document = _documentRepository.LoadDocument(documentId);
     _document.Reject();
     return RedirectToAction("List");
 }
Ejemplo n.º 6
0
 public ActionResult Approve(int documentId)
 {
     _document = _documentRepository.LoadDocument(documentId);
     _document.Publish();
     return RedirectToAction("List");
 }
Ejemplo n.º 7
0
 public ApprovalController(IDocumentRepository documentRepository)
     : base(true)
 {
     _documentRepository = documentRepository;
     _document = new Document(_documentRepository);
 }
Ejemplo n.º 8
0
        public ActionResult Index(int structureId)
        {
            Structure structure = _structureRepository.LoadStructure(structureId);

            _document = _document.Load(structure.StructureID, Status.Live);

            ViewData["Document"] = (_document ?? new Document{});
            return View(structure);
        }
Ejemplo n.º 9
0
 public bool DeleteDocument(Document document)
 {
     throw new NotImplementedException ();
 }
Ejemplo n.º 10
0
        public Document UpdateDocument(Document document)
        {
            Document oldDocument = LoadDocument(document.DocumentID.Value);

            // document object should just set its own properties, but due to 'linq to sql' weirdness we have to set them all here!
            oldDocument.DocumentRootID = document.DocumentRootID;
            oldDocument.DocumentName = document.DocumentName;
            oldDocument.DocumentData = document.DocumentData;
            oldDocument.DocumentStatus = document.DocumentStatus;
            oldDocument.Modified = DateTime.Now;

            _db.SubmitChanges();

            return document;
        }