protected void DeletePetButton_Click(object sender, EventArgs e) { DeleteAttributesRequest deleteRequest = new DeleteAttributesRequest() { DomainName = Properties.Settings.Default.PetBoardPublicDomainName, ItemName = this._itemName }; _simpleDBClient.DeleteAttributes(deleteRequest); if (DomainHelper.DoesDomainExist(this._domainName, _simpleDBClient)) { deleteRequest.DomainName = this._domainName; _simpleDBClient.DeleteAttributes(deleteRequest); } Response.Redirect("~/Default.aspx"); }
private Pet RetrievePetFromPrivateDomain() { string domainToTry = this._domainName; GetAttributesRequest getAttributeRequest = null; GetAttributesResponse response; List <Attribute> attrs = null; if (DomainHelper.DoesDomainExist(this._domainName, _simpleDBClient)) { // // Try to get the requested pet from the user's private domain // getAttributeRequest = new GetAttributesRequest() { DomainName = this._domainName, ItemName = this._itemName }; response = _simpleDBClient.GetAttributes(getAttributeRequest); if (response.Attributes.Count > 0) { attrs = response.Attributes; } else { // If we can't find it try the public domain getAttributeRequest.DomainName = Properties.Settings.Default.PetBoardPublicDomainName; response = _simpleDBClient.GetAttributes(getAttributeRequest); attrs = response.Attributes; } } else if (DomainHelper.DoesDomainExist(Settings.Default.PetBoardPublicDomainName, _simpleDBClient)) { getAttributeRequest = new GetAttributesRequest() { DomainName = Properties.Settings.Default.PetBoardPublicDomainName, ItemName = this._itemName }; response = _simpleDBClient.GetAttributes(getAttributeRequest); attrs = response.Attributes; } // If results is null, attrs is going to be null as well if (attrs != null) { return(new Pet { PhotoThumbUrl = attrs.First(a => a.Name == "PhotoThumbUrl").Value, Name = attrs.First(a => a.Name == "Name").Value, Birthdate = attrs.First(a => a.Name == "Birthdate").Value, Sex = attrs.First(a => a.Name == "Sex").Value, Type = attrs.First(a => a.Name == "Type").Value, Breed = attrs.First(a => a.Name == "Breed").Value, Likes = attrs.First(a => a.Name == "Likes").Value, Dislikes = attrs.First(a => a.Name == "Dislikes").Value }); } else { return(null); } }