Exemplo n.º 1
0
        public ActionResult AddTag(Guid id, string name, string value)
        {
            var versions = new Versions();
            var version = versions.GetVersion(id);
            if (version.Tags.ContainsKey(name))
                throw new HttpException(406, "Tag name already exists");

            version.Tags.Add(name, value);
            versions.UpdateVersion(version);
            if (Request.IsAjaxRequest())
                return Json(null);
            else
                return RedirectToAction("EditTags", new { id = id });
        }
Exemplo n.º 2
0
        public JsonResult UpdateTag(Guid id, string oldName, string name, string value)
        {
            var versions = new Versions();
            var version = versions.GetVersion(id);
            if (!version.Tags.ContainsKey(oldName))
                throw new HttpException(404, "Tag not found");

            if (oldName == name)
            {
                version.Tags[name] = value;
            }
            else if (version.Tags.ContainsKey(name))
            {
                throw new HttpException(406, "Tag name already exists");
            }
            else
            {
                version.Tags.Remove(oldName);
                version.Tags.Add(name, value);
            }
            versions.UpdateVersion(version);
            return Json(null);
        }
Exemplo n.º 3
0
        public JsonResult RemoveTag(Guid id, string name)
        {
            var versions = new Versions();
            var version = versions.GetVersion(id);
            if (!version.Tags.ContainsKey(name))
                throw new HttpException(404, "Tag not found");

            version.Tags.Remove(name);
            versions.UpdateVersion(version);
            return Json(null);
        }
Exemplo n.º 4
0
        public ActionResult Edit(Guid id, string comment)
        {
            Version version = null;
            try
            {
                var versions = new Versions();
                version = versions.GetVersion(id);
                version.Comment = comment;
                versions.UpdateVersion(version);
                return RedirectToAction("Details", new { id = version.Key });
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", ex);
            }

            var groups = new Groups();
            var apps = new Apps();
            Group group = null;
            App app = null;
            if (version != null)
            {
                group = groups.GetGroup(version.GroupKey);
                app = apps.GetApp(version.AppKey);
            }

            var model = new VersionDetails()
            {
                Version = version,
                App = app,
                Group = group,
            };

            return View(model);
        }