Skip to content

Instantly share code, notes, and snippets.

View mortezadalil's full-sized avatar

Morteza Dalil mortezadalil

View GitHub Profile
// Defining a Shadow Property
public class ApplicationDbContext : DbContext
{
public DbSet<Book> Books { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Book>().Property<DateTime>("ModifiedDate");
}
}
// Defining a Shadow Property
public class ApplicationDbContext : DbContext
{
public DbSet<Book> Books { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Book>().Property<DateTime>("ModifiedDate");
}
public class ApplicationDbContext : DbContext
{
public DbSet<Book> Books { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Book>().Property<DateTime>("ModifiedDate");
}
}
namespace DotNetCoreRepository.Repository
{
public class EmployeeRepository : IEmployeeRepository
{
private readonly IConfiguration configuration;
public EmployeeRepository(IConfiguration configuration)
{
this.configuration = configuration;
}
public void AddUpdateEmployee(EmployeeModel em)
using Dapper;
using Microsoft.Extensions.Configuration;
using <YourProjectName>.Application.Interfaces;
using <YourProjectName>.Core.Models;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
namespace <YourProjectName>.Infrastructure.Repositories
using Dapper;
using Microsoft.Extensions.Configuration;
using <YourProjectName>.Application.Interfaces;
using <YourProjectName>.Core.Models;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
namespace <YourProjectName>.Infrastructure.Repositories
using System.Text.Json;
using controllers.ApiModels;
using Microsoft.AspNetCore.Mvc;
namespace controllers.Controllers;
[ApiController]
[Route("Demo")]
public class DemoController : ControllerBase
{
version: '3'
services:
catalog.api:
ports:
- 4000:4300
depends_on:
- catalog.db
environment:
- MONGO_URL=catalogdb:27017
catalog.db:
version: '3'
services:
catalog.api:
image: catalogapi
container_name: catalogapi
build:
context: ./Catalog.Api
dockerfile: dockerfile
catalog.db:
[HttpPost("UpdateBasketItems")]
public async Task<Basket.Api.Models.Basket?> UpdateBasketItems(Basket.Api.Models.Basket basket)
{
using var channel = GrpcChannel.ForAddress(_configuration.GetValue<string>("DiscountGrpcServerUrl"));
var client = new Price.PriceClient(channel);
foreach (var item in basket.BasketItems)
{
var reply = await client.GetPriceAsync(new PriceRequest() { Id = item.ProductId });
if (!string.IsNullOrEmpty(reply.ErrorMessage))