public List<Dictionary<string,AttributeValue>> getAllItems(string ConnectionString, string tableName) { Connection c = new Connection(); var client = c.ConnectAmazonDynamoDB(ConnectionString); var request = new ScanRequest { TableName = tableName, }; var response = client.Scan(request); var result = response.Items; return result; }
public List<Dictionary<string, AttributeValue>> getItemContain(string ConnectionString, string tableName, string inputparam, string columnName) { Connection c = new Connection(); var client = c.ConnectAmazonDynamoDB(ConnectionString); var table = Table.LoadTable(client, tableName); // Define scan conditions Dictionary<string, Condition> conditions = new Dictionary<string, Condition>(); // Title attribute should contain the string "Adventures" Condition titleCondition = new Condition(); titleCondition.ComparisonOperator = "BEGINS_WITH"; titleCondition.AttributeValueList.Add(new AttributeValue { S = inputparam }); conditions[columnName] = titleCondition; var request = new ScanRequest { TableName = tableName, ScanFilter = conditions }; var response = client.Scan(request); var result = response.Items; return result; }
public List<Dictionary<string, AttributeValue>> getItemWithFilters(string ConnectionString, string tableName, List<string> inputparam, List<string> expressionText, List<string> columnName) { Connection c = new Connection(); var client = c.ConnectAmazonDynamoDB(ConnectionString); var table = Table.LoadTable(client, tableName); var strFilterExpression = columnName[0] + " = " + expressionText[0]; var newDictionary = new Dictionary<string, AttributeValue> { {expressionText[0], new AttributeValue { S = inputparam[0]}} }; if (columnName.Count() > 1) { for (int i=1; i < columnName.Count(); i++) { strFilterExpression += " and " + columnName[i] + " = " + expressionText[i]; newDictionary.Add(expressionText[i], new AttributeValue { S = inputparam[i] }); } } var request = new ScanRequest { TableName = tableName, ExpressionAttributeValues = newDictionary, FilterExpression = strFilterExpression }; var response = client.Scan(request); var result = response.Items; return result; }
public List<Dictionary<string, AttributeValue>> getItem(string ConnectionString, string tableName, string inputparam, string expressionText, string columnName) { Connection c = new Connection(); var client = c.ConnectAmazonDynamoDB(ConnectionString); var table = Table.LoadTable(client, tableName); var request = new ScanRequest { TableName = tableName, ExpressionAttributeValues = new Dictionary<string, AttributeValue> { {expressionText, new AttributeValue { S = inputparam}} }, FilterExpression = columnName + "=" + expressionText }; var response = client.Scan(request); var result = response.Items; return result; }
public ActionResult Index(UserProfile model) { var client = new Connection().ConnectAmazonDynamoDB(new AmazonDBHelper().AmazonDBConnectionString()); var table = Table.LoadTable(client, "user"); var item = new Document(); item["email"] = model.Email; item["password"] = model.Password; item["dob"] = model.DOB; item["firstname"] = model.FirstName; item["lastname"] = model.LastName; if (model.MiddleName != null && model.MiddleName != "") item["middlename"] = model.MiddleName; item["gender"] = model.GenderID; item["mobilephone"] = model.MobilePhone; item["usertype"] = model.UserTypeID; var licenses = new Document(); if (model.LicenseExpireDate != null && model.LicenseExpireDate != "") licenses.Add("licenseexpiredate", model.LicenseExpireDate); if (model.LicenseIssueDate != null && model.LicenseIssueDate != "") licenses.Add("licenseissuedate", model.LicenseIssueDate); if (model.LicenseIssuePlace != null && model.LicenseIssuePlace != "") licenses.Add("licenseissueplace", model.LicenseIssuePlace); if (model.LicenseNumber != null && model.LicenseNumber != "") licenses.Add("licensenumber", model.LicenseNumber); item.Add("license", licenses); table.PutItem(item); ListboxHelper g = new ListboxHelper(); model.getAllGender = g.GetAllGender(); model.getAllUserTypes = g.GetAllUserTypes(); return RedirectToAction("AddLocation", "User", new {Email = model.Email }); }
public void UpdateItem(string ConnectionString, string tableName, string whereparam, string expressionText, string columnName, string abbvrName, string updatedValue) { Connection c = new Connection(); var client = c.ConnectAmazonDynamoDB(ConnectionString); var request = new UpdateItemRequest { TableName = tableName, Key = new Dictionary<string, AttributeValue>() { { "TableName", new AttributeValue { S = whereparam } } }, ExpressionAttributeNames = new Dictionary<string, string>() { {abbvrName, columnName} }, ExpressionAttributeValues = new Dictionary<string, AttributeValue>() { {expressionText,new AttributeValue {N = updatedValue}}, }, // This expression does the following: // 1) Adds two new authors to the list // 2) Reduces the price // 3) Adds a new attribute to the item // 4) Removes the ISBN attribute from the item UpdateExpression = "SET " + expressionText + "=" + expressionText + "-" + expressionText }; }
public void InsertItem(string ConnectionString, string tableName, List<string> columnName, List<string> types, List<string> value) { Connection c = new Connection(); var client = c.ConnectAmazonDynamoDB(ConnectionString); var table = Table.LoadTable(client, tableName); var item = new Document(); for (int i = 0; i < columnName.Count(); i++) { if (types[i].ToLower() == "int") item[columnName[i]] = Convert.ToInt32(value[i]); else item[columnName[i]] = value[i]; } table.PutItem(item); }
private bool AddLocation(Location l) { int ID = 1; bool result = false; try { var client = new Connection().ConnectAmazonDynamoDB(new AmazonDBHelper().AmazonDBConnectionString()); //Get ID List<ListboxHelper.CustomListItem> cli = new ListboxHelper().GetTableID(); foreach (var li in cli) { if (li.text == "Location") { ID = li.value; ID += 1; } } var table = Table.LoadTable(client, "location"); var item = new Document(); item["id"] = ID; item["city"] = l.City; item["postalcode"] = l.PostalCode; item["province"] = l.Province; item["street1"] = l.Street1; if (l.Street2 != null && l.Street2 != "") item["street2"] = l.Street2; item["email"] = l.Email; item["locationtypeid"] = l.LocationTypeID; item["locname"] = l.LocName; if (l.LocFax != null && l.LocFax != "") item["locfax"] = l.LocFax; item["locphone"] = l.LocPhoneMain; table.PutItem(item); new CRUD().UpdateItem(new AmazonDBHelper().AmazonDBConnectionString(), "GenerateID", "location", ":i", "ID", "#I", (ID + 1).ToString()); } catch (Exception) { } return result; }
public JsonResult CheckEmail(string Email) { var client = new Connection().ConnectAmazonDynamoDB(new AmazonDBHelper().AmazonDBConnectionString()); var result = new CRUD().getItem(new AmazonDBHelper().AmazonDBConnectionString(), "user", Email, ":v_email", "email"); if (result.Count >= 1) return Json("false"); else return Json("true"); }