Skip to content

Instantly share code, notes, and snippets.

👩‍💻
Coding

Sumit Kharche sumitkharche

👩‍💻
Coding
Block or report user

Report or block sumitkharche

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
@sumitkharche
sumitkharche / AutoMapperProfile.cs
Created Jan 10, 2020
AutoMapperProfile.cs with conditional mappings
View AutoMapperProfile.cs
using AutoMapper;
namespace automapper_sample
{
public class AutoMapperProfile : Profile
{
public AutoMapperProfile()
{
CreateMap<StudentDTO, Student>()
.ForMember(dest => dest.City, opt => opt.MapFrom(src => src.CurrentCity))
@sumitkharche
sumitkharche / AutoMapperProfile.cs
Created Jan 10, 2020
AutoMapperProfile.cs for nested class
View AutoMapperProfile.cs
using AutoMapper;
namespace automapper_sample
{
public class AutoMapperProfile : Profile
{
public AutoMapperProfile()
{
CreateMap<StudentDTO, Student>()
.ForMember(dest => dest.City, opt => opt.MapFrom(src => src.CurrentCity));
@sumitkharche
sumitkharche / AddressDTO.cs
Created Jan 10, 2020
AddressDTO.cs class
View AddressDTO.cs
namespace automapper_sample
{
public class AddressDTO
{
public string State { get; set; }
public string Country { get; set; }
}
}
@sumitkharche
sumitkharche / Automapper.cs
Created Jan 10, 2020
Automapper.cs with projection
View Automapper.cs
namespace automapper_sample
{
public class AutoMapperProfile : Profile
{
public AutoMapperProfile()
{
CreateMap<StudentDTO, Student>()
.ForMember(dest => dest.City, opt => opt.MapFrom(src => src.CurrentCity));
}
}
View StudentController.cs
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
namespace automapper_sample.Controllers
{
[Route("api/[controller]")]
public class StudentController : Controller
{
private readonly IMapper _mapper;
View AutoMapperProfile.cs
using AutoMapper;
namespace automapper_sample
{
public class AutoMapperProfile : Profile
{
public AutoMapperProfile()
{
CreateMap<StudentDTO, Student>();
}
View StudentDTO.cs
namespace automapper_sample
{
public class StudentDTO
{
public string Name { get; set; }
public int Age { get; set; }
public string City { get; set; }
}
}
View Student.cs
namespace automapper_sample
{
public class Student
{
public string Name { get; set; }
public int Age { get; set; }
public string City { get; set; }
}
}
View App.svelte
<script>
import { onMount } from "svelte";
import axios from "axios";
import config from "./config.js";
import TodoItem from "./TodoItem.svelte";
export let name;
let todo = "";
$: todos = [];
onMount(getTodos());
function getTodos() {
View index.html
<!doctype html>
<html>
<head>
<meta charset='utf8'>
<meta name='viewport' content='width=device-width'>
<title>Svelte & Cosmic JS App</title>
<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='/global.css'>
You can’t perform that action at this time.