Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Karthikeyan VK karthikeyanVK

🎯
Focusing
Block or report user

Report or block karthikeyanVK

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View orders.local.settings.json
{
"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"
View OrderedProduct .cs
using System;
namespace PetShop.Model
{
public class OrderedProduct
{
public Guid ProductId;
public int OrderedProductQuantity { get; set; }
}
}
View UpdateProductQuantity.json
{
"ProductName":"Dog1",
"CustomerId":"17EDCACA-C902-431A-B935-A1FCF05CA52A",
"ProductId":"17EDCACb-C902-431A-B935-A1FCF05CA52A",
"OrderedProductQuantity":"20"
}
View UpdateProductQuantity.cs
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;
View UpdateProductQuantity
public bool UpdateProductQuantity(OrderedProduct orderedProduct)
{
using (var context = new PetShopContext())
{
var productFromDb = context.Products.Find(orderedProduct.ProductId);
productFromDb.Quantity -= orderedProduct.OrderedProductQuantity;
context.SaveChanges();
}
View Order.cs
using System;
using Newtonsoft.Json;
namespace PetShop.Model
{
public class Order
{
[JsonProperty(PropertyName = "id")]
public Guid OrderId { get; set; }
public Guid CustomerId { get; set; }
View OrderService.cs
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;
View CosmosDbService.cs
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
{
View ICosmosDbService.cs
using System.Collections.Generic;
using System.Threading.Tasks;
namespace PetShop.DBAccess.CosmosDB
{
public interface ICosmosDbService
{
Task AddItemAsync<T>(T item, string id);
Task<T> GetItemAsync<T>(string id);
Task<IEnumerable<T>> GetItemsAsync<T>(string queryString);
Task UpdateItemAsync<T>(string id, T item);
View productdockerfile
FROM microsoft/dotnet:2.2-sdk AS installer-env
COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish PetShop.Products/PetShop.Products.csproj --output /home/site/wwwroot
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:2.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet:2.0
You can’t perform that action at this time.