public ActionResult DeleteConfirmed(string id) { DBdata dBdata = db.Dbset.Find(id); db.Dbset.Remove(dBdata); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Name,Accounted,Encrypted,Production")] DBdata dBdata) { if (ModelState.IsValid) { db.Entry(dBdata).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dBdata)); }
public ActionResult Create([Bind(Include = "ID,Name,Accounted,Encrypted,Production")] DBdata dBdata) { if (ModelState.IsValid) { db.Dbset.Add(dBdata); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dBdata)); }
// GET: DBdatas/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DBdata dBdata = db.Dbset.Find(id); if (dBdata == null) { return(HttpNotFound()); } return(View(dBdata)); }
private async Task <DialogTurnResult> InsertDBStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { CosmosClient client = new CosmosClient(Startup.CosmosDbEndpoint, Startup.AuthKey); database = await client.CreateDatabaseIfNotExistsAsync(databaseId); ContainerProperties containerProperties = new ContainerProperties(containerId, partitionKeyPath: Startup.PartitionKey); // Create with a throughput of 1000 RU/s container = await database.CreateContainerIfNotExistsAsync( containerProperties, throughput : 1000); var orderData = await _orderDataAccessor.GetAsync(stepContext.Context, () => new OrderData(), cancellationToken); var keyword = (string)stepContext.Result; var sandwich = orderData.Sandwiches.Last(); IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); string ipAddr = string.Empty; for (int i = 0; i < host.AddressList.Length; i++) { if (host.AddressList[i].AddressFamily == AddressFamily.InterNetwork) { ipAddr = host.AddressList[i].ToString(); } } string sJson = JsonConvert.SerializeObject(sandwich); var dbData = new DBdata { id = $"{keyword}", Contents = sandwich, ETag = "x", AccountNumber = ipAddr }; await container.UpsertItemAsync <DBdata>(dbData, new PartitionKey(dbData.AccountNumber)); return(await stepContext.BeginDialogAsync(nameof(OrderEndDialog))); }
private async Task DataUpdateStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var orderData = await _orderDataAccessor.GetAsync(stepContext.Context, () => new OrderData(), cancellationToken); CosmosClient client = new CosmosClient(Startup.CosmosDbEndpoint, Startup.AuthKey); database = await client.CreateDatabaseIfNotExistsAsync(databaseId); ContainerProperties containerProperties = new ContainerProperties(containerId, partitionKeyPath: Startup.PartitionKey); // Create with a throughput of 1000 RU/s container = await database.CreateContainerIfNotExistsAsync( containerProperties, throughput : 1000); //orderNum 가져오기 try { FeedIterator <DBdata> feedIterator = container.GetItemQueryIterator <DBdata>("SELECT top 1 * FROM c order by c._ts desc"); { while (feedIterator.HasMoreResults) { FeedResponse <DBdata> result = await feedIterator.ReadNextAsync(); foreach (var item in result) { orderData.OrderNum = Int32.Parse(item.id); } } } } catch (System.Exception e) { orderData.OrderNum = 0; } //ip IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); string ipAddr = string.Empty; for (int i = 0; i < host.AddressList.Length; i++) { if (host.AddressList[i].AddressFamily == AddressFamily.InterNetwork) { ipAddr = host.AddressList[i].ToString(); } } //Order 데이터 삽입 foreach (Sandwich tempSand in orderData.Sandwiches) { string sJson = JsonConvert.SerializeObject(tempSand); var dbData = new DBdata { id = $"{++orderData.OrderNum}", Contents = tempSand, ETag = "x", AccountNumber = ipAddr }; await container.CreateItemAsync <DBdata>(dbData, new PartitionKey(dbData.AccountNumber)); } //container 변경 containerProperties = new ContainerProperties(countContainerId, partitionKeyPath: "/AccountNumber"); // Create with a throughput of 1000 RU/s container = await database.CreateContainerIfNotExistsAsync( containerProperties, throughput : 1000); //Count 데이터 삽입 foreach (Sandwich tempSand in orderData.Sandwiches) { var CountId = 0; string sauce = ""; tempSand.Sauce.Sort(); foreach (string temp in tempSand.Sauce) { sauce += temp + " "; } //CountId 찾기 try { FeedIterator <DBcount> feedIterator = container.GetItemQueryIterator <DBcount>("SELECT top 1 * FROM c order by c._ts desc"); { while (feedIterator.HasMoreResults) { FeedResponse <DBcount> result = await feedIterator.ReadNextAsync(); foreach (var item in result) { CountId = Int32.Parse(item.id) + 1; } } } } catch (System.Exception e) { CountId = 0; } try { FeedIterator <DBcount> feedIterator = container.GetItemQueryIterator <DBcount>("SELECT * FROM c WHERE c.Sauce='" + sauce + "' and c.Bread ='" + tempSand.Bread + "' and c.Menu ='" + tempSand.Menu + "'"); { if (feedIterator.HasMoreResults) { FeedResponse <DBcount> result = await feedIterator.ReadNextAsync(); DBcount res = result.First(); var count = res.Count + 1; DBcount countData = new DBcount(); countData.id = res.id; countData.Count = count; countData.Sauce = sauce; countData.Menu = tempSand.Menu; countData.ETag = "x"; countData.AccountNumber = "0"; countData.Bread = tempSand.Bread; ItemResponse <DBcount> item = await container.DeleteItemAsync <DBcount>(partitionKey : new PartitionKey("0"), id : res.id); await container.CreateItemAsync(countData, new PartitionKey("0")); } } } catch (System.Exception e) { var countData = new DBcount { id = $"{CountId}", Count = 1, Bread = $"{tempSand.Bread}", Sauce = sauce, Menu = $"{tempSand.Menu}", ETag = "x", AccountNumber = "0" }; await container.CreateItemAsync <DBcount>(countData, new PartitionKey("0")); } } }