Skip to content

Instantly share code, notes, and snippets.

View Defcoq's full-sized avatar

Gallinocoq Defcoq

View GitHub Profile
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ItinnovDesign.SoC.WebUI._Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<form id="form1" runat="server">
<div>
<asp:DropDownList AutoPostBack="true" ID="ddlCustomerType" runat="server" >
<asp:ListItem Value="0">Standard</asp:ListItem>
<asp:ListItem Value="1">Trade</asp:ListItem>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using System.Web.Routing;
using System.Web.Security;
using System.Web.SessionState;
using Autofac;
using Autofac.Core;
public class ProductListPresenter
{
private IProductListView _productListView;
private Service.ProductService _productService;
public ProductListPresenter(IProductListView ProductListView, Service.ProductService ProductService)
{
_productService = ProductService;
_productListView = ProductListView;
}
public interface IProductListView
{
void Display(IList<Service.ProductViewModel> Products);
Model.CustomerType CustomerType { get; }
string ErrorMessage { set; }
}
public class ProductRepository : Model.IProductRepository
{
public IList<Model.Product> FindAll()
{
var products = from p in new ITInnovDesign.SoC.Repository.ProductContext().Products
select new Model.Product
{
Id = p.ProductId,
Name = p.ProductName,
Price = new Model.Price(p.Rrp, p.SellingPrice)
public class ProductService
{
private Model.ProductService _productService;
public ProductService(Model.ProductService ProductService)
{
_productService = ProductService;
}
public ProductListResponse GetAllProductsFor(ProductListRequest productListRequest)
public static class ProductMapperExtensionMethods
{
public static IList<ProductViewModel> ConvertToProductListViewModel(this IList<Model.Product> products)
{
IList<ProductViewModel> productViewModels = new List<ProductViewModel>();
foreach(Model.Product p in products)
{
productViewModels.Add(p.ConvertToProductViewModel());
}
public class ProductListResponse
{
public bool Success { get; set; }
public string Message { get; set; }
public IList<ProductViewModel> Products { get; set; }
}
public class ProductListRequest
{
public CustomerType CustomerType { get; set; }
}
public class ProductViewModel
{
public int ProductId { get; set; }
public string Name { get; set; }
public string RRP { get; set; }
public string SellingPrice { get; set; }
public string Discount { get; set; }
public string Savings { get; set; }
}