Skip to content

Instantly share code, notes, and snippets.

.folders {
background-color: #bbb;
list-style-type: none;
padding: 0;
margin: 0;
border-radius: 7px;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #d6d6d6), color-stop(0.4, #c0c0c0), color-stop(1,#a4a4a4));
margin: 10px 0 16px 0;
font-size: 0px;
}
@page
@model WebMailModel
@{
ViewData["Title"] = "WebMail";
}
<h2>WebMail</h2>
<ul class="folders" data-bind="foreach: folders">
<li data-bind="text: $data,
css: { selected: $data == $root.chosenFolderId() },
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;
function WebmailViewModel() {
// Data
var self = this;
self.folders = ['Inbox', 'Archive', 'Sent', 'Spam'];
self.chosenFolderId = ko.observable();
self.chosenFolderData = ko.observable();
self.chosenMailData = ko.observable();
// Behaviours
self.goToFolder = function(folder) {
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
{
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