public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DisassociateRouteTableResponse response = new DisassociateRouteTableResponse();

            while (context.Read())
            {
            }


            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DisassociateRouteTableResponse response = new DisassociateRouteTableResponse();

            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth = 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                }
            }

            return(response);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int ID, [Bind("ID,Name,Type,IPv4CIDR,IPv6CIDR")] Subnet Newsubnet)
        {
            var subnet = await _context.Subnets.FindAsync(ID);

            if (subnet == null)
            {
                return(NotFound());
            }
            else if (!subnet.ID.Equals(Newsubnet.ID) || !subnet.IPv4CIDR.Equals(Newsubnet.IPv4CIDR) || !subnet.IPv6CIDR.Equals(Newsubnet.IPv6CIDR))
            {
                return(StatusCode(500));
            }
            else if (subnet.editable == false)
            {
                ViewData["Exception"] = "You cannot edit a default subnet!";
                return(View(subnet));
            }
            else
            {
                if (!subnet.Name.Equals(Newsubnet.Name))
                {
                    await EC2Client.DeleteTagsAsync(new DeleteTagsRequest
                    {
                        Resources = new List <string>
                        {
                            subnet.AWSVPCSubnetReference
                        },
                        Tags = new List <Tag>
                        {
                            new Tag("Name")
                        }
                    });

                    await EC2Client.CreateTagsAsync(new CreateTagsRequest
                    {
                        Resources = new List <string>
                        {
                            subnet.AWSVPCSubnetReference
                        },
                        Tags = new List <Tag>
                        {
                            new Tag("Name", Newsubnet.Name)
                        }
                    });

                    subnet.Name = Newsubnet.Name;
                }
                if (subnet.Type != Newsubnet.Type)
                {
                    try
                    {
                        DisassociateRouteTableResponse responseD = await EC2Client.DisassociateRouteTableAsync(new DisassociateRouteTableRequest
                        {
                            AssociationId = subnet.AWSVPCRouteTableAssoicationID
                        });

                        if (responseD.HttpStatusCode == HttpStatusCode.OK)
                        {
                            AssociateRouteTableRequest requestA = new AssociateRouteTableRequest
                            {
                                SubnetId = subnet.AWSVPCSubnetReference
                            };
                            if (Newsubnet.Type == Models.SubnetType.Internet)
                            {
                                RouteTable Internet = await _context.RouteTables.FindAsync(1);

                                requestA.RouteTableId = Internet.AWSVPCRouteTableReference;
                            }
                            else if (Newsubnet.Type == Models.SubnetType.Extranet)
                            {
                                RouteTable Extranet = await _context.RouteTables.FindAsync(2);

                                requestA.RouteTableId = Extranet.AWSVPCRouteTableReference;
                            }
                            else if (Newsubnet.Type == Models.SubnetType.Intranet)
                            {
                                RouteTable Intranet = await _context.RouteTables.FindAsync(3);

                                requestA.RouteTableId = Intranet.AWSVPCRouteTableReference;
                            }
                            AssociateRouteTableResponse responseA = await EC2Client.AssociateRouteTableAsync(requestA);

                            if (responseA.HttpStatusCode == HttpStatusCode.OK)
                            {
                                subnet.Type = Newsubnet.Type;
                            }
                            else
                            {
                                if (subnet.Type == Models.SubnetType.Internet)
                                {
                                    RouteTable Internet = await _context.RouteTables.FindAsync(1);

                                    requestA.RouteTableId = Internet.AWSVPCRouteTableReference;
                                }
                                else if (subnet.Type == Models.SubnetType.Extranet)
                                {
                                    RouteTable Extranet = await _context.RouteTables.FindAsync(2);

                                    requestA.RouteTableId = Extranet.AWSVPCRouteTableReference;
                                }
                                else if (subnet.Type == Models.SubnetType.Intranet)
                                {
                                    RouteTable Intranet = await _context.RouteTables.FindAsync(3);

                                    requestA.RouteTableId = Intranet.AWSVPCRouteTableReference;
                                }
                                await EC2Client.AssociateRouteTableAsync(requestA);

                                ViewData["Exception"] = "Edit Failed! - Route Table linking Failed";
                                return(View(subnet));
                            }
                        }
                        else
                        {
                            ViewData["Exception"] = "Edit Failed!";
                            return(View(subnet));
                        }
                    }
                    catch (AmazonEC2Exception e)
                    {
                        ViewData["Exception"] = e;
                        return(View(subnet));
                    }
                }
                try
                {
                    _context.Update(subnet);
                    await _context.SaveChangesAsync();

                    TempData["Result"] = "Successfully Modified!";
                    return(RedirectToAction("Index"));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (await _context.Subnets.FindAsync(subnet.ID) == null)
                    {
                        TempData["Result"] = "Subnet is gone! The subnet may have been modifed by another user";
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["Result"] = "Subnet has been updated since you last clicked! No modification has been made";
                        return(RedirectToAction("Index"));
                    }
                }
            }
        }