public ActionResult PublishAzure(int id = 0)
        {
            try
            {
                if (id == 0)
                {
                    return(HttpNotFound());
                }

                Application application = applicationRepository
                                          .FindFirst(ap => ap.Member.username == User.Identity.Name && ap.Id == id);

                if (application != null)
                {
                    if (application.generated.HasValue && application.generated.Value)
                    {
                        string    projectFileName = application.Name.Replace(" ", "");
                        WebDeploy deploy          = new WebDeploy();
                        string    publicId        = application.Member.public_id;
                        string    appFile         = Server.MapPath("~/App_Data/" + publicId + "/" + application.Name + "_" + application.Id + "/" + projectFileName + ".csproj");
                        string    pubXml          = Server.MapPath("~/App_Data/" + publicId + "/" + application.Name + "#" + application.url + ".pubxml");

                        string res = deploy.BuildApp(appFile, pubXml);
                        if (res == "Success")
                        {
                            return(View("AzureSuccess", new MessageView()
                            {
                                Message = application.url
                            }));
                        }
                        else
                        {
                            return(View("Error", new MessageView()
                            {
                                Message = res//"An error occured, Application not Published."
                            }));
                        }
                    }

                    return(RedirectToAction("Details", new { id = id }));
                }
            }
            catch (Exception ex)
            {
                return(View("Error", new MessageView()
                {
                    Message = ex.Message
                }));
            }
            return(RedirectToAction("Index"));
        }
Example #2
0
        public void FromPublishProfile_ToYml_ReturnsYml()
        {
            var       yml    = BuildYml();
            WebDeploy deploy = new WebDeploy()
            {
                Server   = "bleh",
                Website  = "www.site.com",
                Username = "******",
                Password = "******"
            };

            var result = deploy.ToYml();

            Assert.Equal(yml, result);
        }
Example #3
0
        public void FromPublishProfile_ValidXml_ReturnsObject()
        {
            var    profile     = BuildPublishProfile();
            string server      = "https://super-cool-service.scm.azurewebsites.net:443/msdeploy.axd?site=super-cool-service";
            string websiteName = "super-cool-service";
            string username    = "******";
            string password    = "******";

            var result = WebDeploy.FromPublishProfile(profile);

            Assert.Equal(server, result.Server);
            Assert.Equal(websiteName, result.Website);
            Assert.Equal(username, result.Username);
            Assert.Equal(password, result.Password);
        }
        public IActionResult Index(string model, string apiToken = null)
        {
            WebDeploy result = null;

            try
            {
                result = WebDeploy.FromPublishProfile(model, apiToken);
            }
            catch (Exception)
            {
                return(BadRequest());
            }

            return(Ok(result));
        }
Example #5
0
 public void FromPublishProfile_NullXml_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(() => WebDeploy.FromPublishProfile(null));
     Assert.Throws <ArgumentNullException>(() => WebDeploy.FromPublishProfile(""));
     Assert.Throws <ArgumentNullException>(() => WebDeploy.FromPublishProfile(" "));
 }