Skip to content

Instantly share code, notes, and snippets.

View karthikeyanVK's full-sized avatar
🎯
Focusing

Karthikeyan VK karthikeyanVK

🎯
Focusing
View GitHub Profile
environment: development
apphost: k8s
products:
label:
name: aspnet3core
container:
name: aspnet3
name: aspnet3-demo
version: 1.0.0
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"DatabaseName": "petshopapps",
"ContainerName": "orders",
"Account": "https://petshopapps.documents.azure.com:443/",
"CosmosKey": "sBlINeLXdn9PLk157Zu3PGMQ7hljAvZF02LOYrjLdqJO5GTHhro79WlxsGPXQT7GF4KptfJnsnqhjDaKZgRHXA==",
"ProductBaseUrl": "http://localhost:7071/api/UpdateProductQuantity"
using System;
namespace PetShop.Model
{
public class OrderedProduct
{
public Guid ProductId;
public int OrderedProductQuantity { get; set; }
}
}
{
"ProductName":"Dog1",
"CustomerId":"17EDCACA-C902-431A-B935-A1FCF05CA52A",
"ProductId":"17EDCACb-C902-431A-B935-A1FCF05CA52A",
"OrderedProductQuantity":"20"
}
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using PetShop.Business;
using PetShop.Model;
public bool UpdateProductQuantity(OrderedProduct orderedProduct)
{
using (var context = new PetShopContext())
{
var productFromDb = context.Products.Find(orderedProduct.ProductId);
productFromDb.Quantity -= orderedProduct.OrderedProductQuantity;
context.SaveChanges();
}
using System;
using Newtonsoft.Json;
namespace PetShop.Model
{
public class Order
{
[JsonProperty(PropertyName = "id")]
public Guid OrderId { get; set; }
public Guid CustomerId { get; set; }
using System;
using PetShop.DBAccess.CosmosDB;
using PetShop.Model;
using PetShop.DBAccess.CosmosDB;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos;
using Microsoft.Azure.Cosmos.Fluent;
namespace PetShop.DBAccess.CosmosDB
{