public ActionResult AssignDcSubject(AssignViewModel avm, string dcButton)
        {
            dcButton = Regex.Replace(dcButton, @" \(...\)", "");
            int parsedPid;

            if (avm.NewDcResource == null)
            {
                TempData["Message"] = "No PID supplied";
            }
            else if (!int.TryParse(avm.NewDcResource, out parsedPid))
            {
                TempData["Message"] = "PID must be a number";
            }
            else
            {
                var fullDoc = GetSubjectDocByUuid(avm.Doc._id);
                if (fullDoc.dcSubject == null)
                {
                    fullDoc.dcSubject = new List <DcEntry>();
                }

                var entry = new DcEntry {
                    type = dcButton, uri = ConfigurationManager.AppSettings["DigitalCollectionsUrl"] + avm.NewDcResource
                };

                fullDoc.dcSubject.Add(entry);

                SaveSubjectDoc(fullDoc);
                TempData["Message"] = "Resource Added";
            }

            return(RedirectToAction("Subject", new { id = avm.Doc._id }));
        }
        public ActionResult AssignDcName(AssignViewModel avm, string dcButton)
        {
            int parsedPid;

            if (avm.NewDcResource == null)
            {
                TempData["Message"] = "No PID supplied";
            }
            else if (!int.TryParse(avm.NewDcResource, out parsedPid))
            {
                TempData["Message"] = "PID must be a number";
            }
            else
            {
                var fullDoc = GetNameDocByUuid(avm.Doc._id);
                if (fullDoc.dcName == null)
                {
                    fullDoc.dcName = new List <DcEntry>();
                }

                var entry = new DcEntry {
                    type = dcButton, uri = ConfigurationManager.AppSettings["DigitalCollectionsUrl"] + avm.NewDcResource
                };

                if (avm.RelatorLabel != null && avm.RelatorUri != null)
                {
                    entry.relator_uri   = avm.RelatorUri;
                    entry.relator_label = avm.RelatorLabel;
                }

                fullDoc.dcName.Add(entry);

                SaveNameDoc(fullDoc);
                TempData["Message"] = "Resource Added";
            }

            return(RedirectToAction("Name", new { id = avm.Doc._id }));
        }