public JsonResult Create( string documentType, string documentTags, string documentOwner, string acountNumber, string description) { string[] tagList = null; int docOwnerId; int docTypeId; var saveStatus = false; if (Int32.TryParse(documentOwner.Split(',')[0], out docOwnerId) && Int32.TryParse(documentType, out docTypeId)) { var docOwner = _customerBL.GetCustomer(docOwnerId); var docType = _documentTypeBL.GetDocumentTypeById(docTypeId); //Initialize list to hold documents to be added to document var docTags = new List <DocumentTag>(); //Retreive documents from string of documentTags if (!String.IsNullOrEmpty(documentTags)) { //Get array of documentTagIds from string of documentTags from request tagList = documentTags.Split(','); //Retreive documents tags belonging to the selected document tag var docTagList = _documentArchivingProcess.GetDocumentTagsInDocumentType(docTypeId); //Get docs to be added to document foreach (var tag in tagList.ToList()) { var docTag = docTagList.FirstOrDefault(d => d.Id == Int32.Parse(tag)); docTags.Add(docTag); } } var document = new Document() { DocumentType = docType, Description = description, DocumentOwner = docOwner, DocumentTags = docTags }; //Save document saveStatus = _documentArchivingProcess.SaveDocument(document); } return(Json(saveStatus ? 1 : 0, JsonRequestBehavior.AllowGet)); }
public JsonResult FilterByDocumentType(int documentTypeId = 0) { // Get all the document tags in the document type var documentTags = _documentArchivingProcess.GetDocumentTagsInDocumentType(documentTypeId); var documentTagsList = new Dictionary <int, string>(); if (documentTags != null) { if (documentTags.Any()) { foreach (var docTag in documentTags) { documentTagsList.Add(docTag.Id, docTag.Name); } } } return(Json(documentTagsList.ToList(), JsonRequestBehavior.AllowGet)); }