Example #1
0
        public static void Run(string[] args)
        {
            string comment;
            string directoryPath;
            Guid appKey;
            ControllerConfiguration context;

            ParseArguments(args, out comment, out directoryPath, out appKey, out context);

            var versionsController = new Versions(context);
            var appsController = new Apps(context);
            var revision = appsController.PushAppRevision(appKey);
            var newVersion = new Version()
            {
                VersionNumber = revision,
                Comment = comment,
                AppKey = appKey,
            };
            versionsController.PushVersion(new DirectoryInfo(directoryPath), newVersion.Key);
            versionsController.CreateVersion(newVersion);
        }
        public ActionResult Create(Guid aid, string comment, DateTime timestamp)
        {
            var apps = new Apps();
            var app = apps.GetApp(aid);

            var newVersion = new Version()
            {
                AppKey = aid,
                Comment = comment,
                Timestamp = timestamp,
                VersionNumber = string.Format("{0}.{1}", app.MajorVersion, app.Revision),
            };

            if (string.IsNullOrWhiteSpace(comment)) ModelState.AddModelError("comment", "Comment is required.");

            if (ModelState.IsValid)
            {
                try
                {
                    var versions = new Versions();
                    versions.CreateVersion(newVersion);

                    app.Revision += 1;
                    apps.UpdateApp(app);

                    return RedirectToAction("Details", new { id = newVersion.Key });
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Error", ex);
                }
            }

            var groups = new Groups();

            var group = groups.GetGroup(app.GroupKey);

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

            return View(model);
        }