Exemplo n.º 1
0
        public async Task <ActionResult> Edit([Bind(Include = "AptID,Descripcion,PersonaID,Precio,Foto1,Foto2,Foto3")] Apt apt)
        {
            if (ModelState.IsValid)
            {
                db.Entry(apt).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.PersonaID = new SelectList(db.Persona, "PersonaID", "Nombre", apt.PersonaID);
            return(View(apt));
        }
Exemplo n.º 2
0
        // GET: Apt/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Apt apt = await db.Apt.FindAsync(id);

            if (apt == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PersonaID = new SelectList(db.Persona, "PersonaID", "Nombre", apt.PersonaID);
            return(View(apt));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Details(int?idApt)
        {
            if (idApt == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Apt apt = await db.Apt.FindAsync(idApt.ToString());

            Persona persona = await db.Persona.FindAsync(apt.PersonaID);

            ViewBag.objPersona = persona;
            ViewBag.fecha      = DateTime.Now.ToShortDateString();
            if (apt == null)
            {
                return(HttpNotFound());
            }
            return(View(apt));
        }
Exemplo n.º 4
0
        // GET: Apt/Create
        public async Task <ActionResult> Create(int?idPersona, int idApt)
        {
            var apt = await db.AptSolo.FindAsync(idApt);

            var aptAlugado = new Apt();

            if (idPersona != null)
            {
                aptAlugado.AptsIdentificador = apt.AptSoloID.ToString();
                aptAlugado.PersonaID         = (int)idPersona;
                ViewBag.PersonaID            = aptAlugado.PersonaID;
                var person = new Persona();
                person = await db.Persona.FindAsync(idPersona);

                ViewBag.PersonaName    = person.Nombre;
                aptAlugado.Descripcion = apt.Descripcion;
                aptAlugado.Precio      = apt.Precio;
                aptAlugado.Foto1       = apt.Foto1;
                aptAlugado.Foto2       = apt.Foto2;
                aptAlugado.Foto3       = apt.Foto3;
                ViewBag.LlegoId        = true;
                aptAlugado.FechaInicio = DateTime.Now.ToShortDateString();

                return(View(aptAlugado));
            }
            else
            {
                aptAlugado.AptsIdentificador = apt.AptSoloID.ToString();
                aptAlugado.Descripcion       = apt.Descripcion;
                aptAlugado.Precio            = apt.Precio;
                aptAlugado.Foto1             = apt.Foto1;
                aptAlugado.Foto2             = apt.Foto2;
                aptAlugado.Foto3             = apt.Foto3;
                aptAlugado.FechaInicio       = DateTime.Now.ToShortDateString();
                ViewBag.PersonaID            = new SelectList(db.Persona, "PersonaID", "Nombre");
                return(View(aptAlugado));
            }
        }
Exemplo n.º 5
0
        public async Task <ActionResult> Create(Apt apt)
        {
            if (ModelState.IsValid)
            {
                var aptSolo = await db.AptSolo.FindAsync(int.Parse(apt.AptsIdentificador));

                apt.Foto1 = aptSolo.Foto1;
                apt.Foto2 = aptSolo.Foto2;
                apt.Foto3 = aptSolo.Foto3;
                db.Apt.Add(apt);


                aptSolo.Alugado         = true;
                db.Entry(aptSolo).State = EntityState.Modified;

                await db.SaveChangesAsync();

                return(RedirectToAction("Index1"));
            }

            ViewBag.PersonaID = new SelectList(db.Persona, "PersonaID", "Nombre", apt.PersonaID);
            return(View(apt));
        }
Exemplo n.º 6
0
        public ActionResult ExternalAffairs(RADViewModel model)
        {
            var obj = new Apt();

            obj.categoryID    = model.categoryID;
            obj.subcategoryID = model.subcategoryID;
            obj.fiscalYearID  = model.fiscalYearID;
            //obj.QuarterOptionID = model.quarteroptionID;



            //ENROLLMENT CHART
            Highcharts apptoJaxChart = new Highcharts("apptoJaxChart");

            apptoJaxChart.InitChart(new Chart()
            {
                Type            = DotNet.Highcharts.Enums.ChartTypes.Column,
                BackgroundColor = new BackColorOrGradient(System.Drawing.Color.White),
                Style           = "fontWeight: 'bold', fontSize: '17px'",
                BorderColor     = System.Drawing.Color.Gray,
                BorderRadius    = 0,
                BorderWidth     = 2
            });

            apptoJaxChart.SetTitle(new Title()
            {
                Text = " "
            });


            // Create objects for X - Axis
            object[] Q1Goal   = Q1GoalsCityCouncil(obj.subcategoryID, obj.categoryID, obj.fiscalYearID).Cast <object>().ToArray();
            object[] Q1Actual = Q1ActualCityCouncil(obj.subcategoryID, obj.categoryID, obj.fiscalYearID).Cast <object>().ToArray();
            //object[] xaxis = Q2GoalsCityCouncil(obj.subcategoryID, obj.categoryID, obj.fiscalYearID).cast<object>().ToArray();
            //object[] Q2Actual = Q2GoalCityCouncil().cast<object>().ToArray();
            //object[] Q3Goal = Q3GoalCityCouncil().cast<object>().ToArray();
            //object[] Q3Actual = Q3GoalCityCouncil().cast<object>().ToArray();
            //object[] Q4Goal = Q4GoalCityCouncil().cast<object>().ToArray();
            //object[] Q4Actual = Q4GoalCityCouncil().cast<object>().ToArray();

            // Create objects for Y - Axis
            string[] Quarters = Qter().ToArray();


            apptoJaxChart.SetXAxis(new XAxis()
            {
                Type  = AxisTypes.Category,
                Title = new XAxisTitle()
                {
                    Text = "Goal vs Actual", Style = "fontWeight: 'bold', fontSize: '17px'"
                },
                Categories = Quarters
            });

            apptoJaxChart.SetYAxis(new YAxis()
            {
                Title = new YAxisTitle()
                {
                    Text  = "# Of Applications",
                    Style = "fontWeight: 'bold', fontSize: '17px'"
                },
                ShowFirstLabel = true,
                ShowLastLabel  = true,
                Min            = 0
            });

            apptoJaxChart.SetLegend(new Legend
            {
                Enabled         = true,
                BorderRadius    = 6,
                BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFADD8E6"))
            });


            // Set series for quarterly goals + actuals
            apptoJaxChart.SetSeries(new Series[]
            {
                new Series {
                    Name  = "Q1 GOAL",
                    Data  = new Data(Q1Goal),
                    Color = ColorTranslator.FromHtml("#3EC2CF")
                },

                new Series
                {
                    Name  = "Q1 ACTUAL",
                    Data  = new Data(Q1Actual),
                    Color = ColorTranslator.FromHtml("#bedde0")
                }
            });



            ChartModel modelChart = new ChartModel();

            modelChart.Chart6 = apptoJaxChart;

            return(View(apptoJaxChart));
        }
Exemplo n.º 7
0
        public void CreateScript()
        {
            var script = new BashScript {
                Comment("Setup environment"),

                Set("INSTANCE_ID", "$(curl -s http://169.254.169.254/latest/meta-data/instance-id)"),

                new IfStatement(IsDefined("$1"), Set("APP_NAME", "$1")),
                new IfStatement(IsDefined("$2"), Set("APP_VERSION", "$2")),

                // TODO: Use shorter syntax...
                new IfStatement(IsDefined("$3"),
                                then: new[] { Set("APP_PACKAGE_URL", "$3") },
                                elseThen: new[] { Set("APP_PACKAGE_URL", "s3://folder/$APP_NAME/$APP_VERSION.tar.gz") }
                                ),

                Set("APP_ROOT", "/var/apps/$APP_NAME/$APP_VERSION"),

                Empty, Echo("Configuring $APP_NAME/$APP_VERSION"),

                // Install depedencies
                Apt.Install("awscli", "nginx", "libunwind8", "libcurl4-openssl-dev"),

                // Configure S3 to allow encrypted package downloads
                "sudo aws configure set s3.signature_version s3v4",

                // Install SSM  agent
                "cd /tmp",

                Wget.Download(
                    new Uri("https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb")
                    ),

                "sudo dpkg -i amazon-ssm-agent.deb",

                Systemctl.Enable("amazon-ssm-agent"),

                // Configure Ngnix ------------------------------------------------------------------------------------------------
                Empty, Echo("Configuring nginx"),

                Wget.Download(
                    url: new Uri("https://unknown/nginx.config"),
                    destination: "/etc/nginx/sites-available/default",
                    sudo: true
                    ),

                Nginx.Reload(),

                // Setup program directories
                "mkdir -p $APP_ROOT",

                // Install the app ------------------------------------------------------------------------------------------------

                // Create a working directory for download
                "mkdir -r /tmp/programs/$APP_NAME/$APP_VERSION",

                // Download the app
                Aws.S3.Copy(
                    source: "$APP_PACKAGE_URL",
                    target: "/tmp/programs/$APP_NAME/$APP_VERSION",
                    options: AwsOptions.Quiet,
                    sudo: true
                    ),

                // Extract the app
                Tar.Extract(
                    file: "/tmp/programs/$APP_NAME/$APP_VERSION",
                    directory: "$APP_ROOT",
                    stripFirstLevel: true
                    ),

                // Create a symbolic link
                CreateSymbolicLink(
                    target: "$APP_ROOT",
                    link: "/var/apps/$APP_NAME/latest",
                    options: SymbolicLinkOptions.Symbolic | SymbolicLinkOptions.Force,  // update if it already exists
                    sudo:    true
                    ),

                // Give permissions to www-data
                Chown(owner: "www-data", path: "/var/apps", recursive: true, sudo: true),

                // Configure the service ------------------------------------------------------------------------------------------
                Empty, Echo("Configuring $APP_NAME.service"),

                // Setup the service
                Aws.S3.Copy(
                    source: "s3://folder/$APP_NAME/$APPNAME.service",
                    target: "/etc/systemd/system/$APP_NAME.service",
                    options: AwsOptions.Quiet,
                    sudo: true
                    ),

                Systemctl.Enable("$APP_NAME.service"),
                Systemctl.Start("$APP_NAME.service"),

                // Cleanup -------------------------------------------------------------------------------------------------------
                Empty, Echo("Cleaning up"),

                new Command("rm -r /tmp/programs/$APP_NAME/$APP_VERSION"),

                // Report to homebase ---------------------------------------------------------------------------------------------
                Empty, Echo("Phoning home $INSTANCE_ID"),

                "curl --data \"status=running\" https://cloud/hosts/aws:$INSTANCE_ID"
            };


            Assert.Equal(@"#!/bin/bash
# Setup environment
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
if [ -n ""$1"" ]; then APP_NAME=$1; fi
if [ -n ""$2"" ]; then APP_VERSION=$2; fi
if [ -n ""$3"" ]; then APP_PACKAGE_URL=$3; else APP_PACKAGE_URL=s3://folder/$APP_NAME/$APP_VERSION.tar.gz; fi
APP_ROOT=/var/apps/$APP_NAME/$APP_VERSION

echo ""Configuring $APP_NAME/$APP_VERSION""
sudo apt install -y awscli nginx libunwind8 libcurl4-openssl-dev
sudo aws configure set s3.signature_version s3v4
cd /tmp
wget -v ""https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb""
sudo dpkg -i amazon-ssm-agent.deb
sudo systemctl enable amazon-ssm-agent

echo ""Configuring nginx""
sudo wget -v ""https://unknown/nginx.config"" -O /etc/nginx/sites-available/default
sudo nginx -s reload
mkdir -p $APP_ROOT
mkdir -r /tmp/programs/$APP_NAME/$APP_VERSION
sudo aws s3 cp --quiet $APP_PACKAGE_URL /tmp/programs/$APP_NAME/$APP_VERSION
tar -xf /tmp/programs/$APP_NAME/$APP_VERSION --strip 1 -C $APP_ROOT
sudo ln -sfn $APP_ROOT /var/apps/$APP_NAME/latest
sudo chown -R www-data /var/apps

echo ""Configuring $APP_NAME.service""
sudo aws s3 cp --quiet s3://folder/$APP_NAME/$APPNAME.service /etc/systemd/system/$APP_NAME.service
sudo systemctl enable $APP_NAME.service
sudo systemctl start $APP_NAME.service

echo ""Cleaning up""
rm -r /tmp/programs/$APP_NAME/$APP_VERSION

echo ""Phoning home $INSTANCE_ID""
curl --data ""status=running"" https://cloud/hosts/aws:$INSTANCE_ID", script.ToString());
        }