Skip to content

Instantly share code, notes, and snippets.

import * as ko from "../lib/knockout/dist/knockout";
class WebMailViewModel {
// Data
folders: string[] = ["Inbox", "Archive", "Sent", "Spam"];
chosenFolderId: KnockoutObservable<string> = new ko.observable();
chosenFolderData: KnockoutObservable<Folder> = new ko.observable();
chosenMailData: KnockoutObservable<Mail> = new ko.observable();
goToFolder: (folder: string) => void;
goToMail: (mail: Mail) => void;
using System;
using System.Collections.Generic;
namespace KnockoutTS.Models
{
public class WebMail
{
public List<Folder> Folders { get; set; } = new List<Folder>();
}
public class Mail
using KnockoutTS.Models;
using Microsoft.AspNetCore.Hosting;
using Newtonsoft.Json;
using System.IO;
using System.Linq;
namespace KnockoutTS.Services
{
public interface IMailService
{
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
using KnockoutTS.Models;
using KnockoutTS.Services;
using Microsoft.AspNetCore.Mvc;
namespace KnockoutTS.Controllers
{
[Route("api/[controller]")]
public class MailController : Controller
{
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es6",
"module": "amd"
},
public class Customer
{
public int CustomerId { get; set; }
public string Name { get; set; }
public ICollection<Order> Orders { get; set; } = new HashSet<Order>();
}
public class Order
{
public int OrderId { get; set; }
create view OrderHeaders as
select c.Name as CustomerName,
o.DateCreated,
sum(oi.Price) as TotalPrice,
count(oi.Price) as TotalItems
from OrderItems oi
inner join Orders o on oi.OrderId = o.OrderId
inner join Customers c on o.CustomerId = c.CustomerId
group by oi.OrderId, c.Name, o.DateCreated
public class OrderHeader
{
public string CustomerName { get; set; }
public DateTime DateCreated { get; set; }
public int TotalItems { get; set; }
public decimal TotalPrice { get; set; }
}
public class SampleContext : DbContext
{
public DbSet<Order> Orders { get; set; }
public DbSet<OrderItem> OrderItems { get; set; }
public DbSet<Customer> Customers { get; set; }
public DbQuery<OrderHeader> OrderHeaders { get; set; }
...
}