1  Doamin    酒店

namespace Nop.Core.Domain.Hotels
{
/// <summary>
/// 酒店
/// </summary>
public partial class Hotel : BaseEntity
{
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string Telephone { get; set; }
/// <summary>
/// 介绍
/// </summary>
public string Introduce { get; set; }
/// <summary>
/// 星级
/// </summary>
public int Level { get; set; } /// <summary>
/// Gets or sets the shipping address identifier
/// </summary>
public int? AddressId { get; set; } /// <summary>
/// Gets or sets the shipping address
/// </summary>
public virtual Address Address { get; set; }
}
}

2  数据库 表

/****** Object:  Table [dbo].[Hotel]    Script Date: 10/27/2016 09:11:41 ******/
SET ANSI_NULLS ON
GO SET QUOTED_IDENTIFIER ON
GO CREATE TABLE [dbo].[Hotel](
[Id] [int] IDENTITY(,) NOT NULL,
[Name] [nvarchar]() NULL,
[Telephone] [nvarchar]() NULL,
[Introduce] [nvarchar]() NULL,
[Level] [int] NULL,
[AddressId] [int] NULL,
CONSTRAINT [PK_Hotel] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] GO

3 Map

using Nop.Core.Domain.Hotels;

namespace Nop.Data.Mapping.Hotels
{
public partial class HotelMap : NopEntityTypeConfiguration<Hotel>
{
public HotelMap()
{
this.ToTable("Hotel");
this.HasKey(f => f.Id);
this.Property(f => f.Name).IsRequired().HasMaxLength(); }
}
}

4 Services 层

using System.Collections.Generic;
using Nop.Core;
using Nop.Core.Domain.Hotels; namespace Nop.Services.Hotels
{
public partial interface IHotelService
{
/// <summary>
/// Deletes a news
/// </summary>
/// <param name="hotel">News item</param>
void DeleteHotel(Hotel hotel); Hotel GetHotelById(int hotelId); IList<Hotel> GetHotelByIds(int[] hotelIds); IPagedList<Hotel> GetAllHotels( int pageIndex = , int pageSize = int.MaxValue, bool showHidden = false); void InsertHotel(Hotel hotel); void UpdateHotel(Hotel hotel); }
}

service

using System;
using System.Collections.Generic;
using System.Linq;
using Nop.Core;
using Nop.Core.Data;
using Nop.Core.Domain.Hotels;
using Nop.Services.Events; namespace Nop.Services.Hotels
{
public partial class HotelService : IHotelService
{
#region Fields private readonly IRepository<Hotel> _hotelRepository;
private readonly IEventPublisher _eventPublisher; #endregion #region Ctor
public HotelService(IRepository<Hotel> hotelRepository, IEventPublisher eventPublisher)
{
_hotelRepository = hotelRepository;
_eventPublisher = eventPublisher;
} #endregion public void DeleteHotel(Hotel hotel)
{
if (hotel == null)
throw new ArgumentNullException("hotel"); _hotelRepository.Delete(hotel); //event notification
_eventPublisher.EntityDeleted(hotel);
} public Hotel GetHotelById(int hotelId)
{
if (hotelId == )
return null; return _hotelRepository.GetById(hotelId);
} public IList<Hotel> GetHotelByIds(int[] hotelIds)
{
var query = _hotelRepository.Table; return query.Where(p=>hotelIds.Contains(p.Id)).ToList();
} public IPagedList<Hotel> GetAllHotels(int pageIndex = , int pageSize = int.MaxValue, bool showHidden = false)
{
var query = _hotelRepository.Table;
var hotels = new PagedList<Hotel>(query, pageIndex, pageSize);
return hotels; } public void InsertHotel(Hotel hotel)
{
if (hotel == null)
throw new ArgumentNullException("hotel"); _hotelRepository.Insert(hotel); //event notification
_eventPublisher.EntityInserted(hotel);
} public void UpdateHotel(Hotel hotel)
{
if (hotel == null)
throw new ArgumentNullException("hotel"); _hotelRepository.Update(hotel); //event notification
_eventPublisher.EntityUpdated(hotel);
}
}
}

Nopcommerce 二次开发1 基础的更多相关文章

  1. Nopcommerce 二次开发0

    Nopcommerce  是国外的一个高质量的开源b2c网站系统,基于EntityFramework6.0和MVC5.0,使用Razor模板引擎,有很强的插件机制,包括支付配送功能都是通过插件来实现的 ...

  2. Ecshop二次开发必备基础

    EcShop二次开发学习方法 近年来,随着互联网的发展,电子商务也跟着一起成长,B2B,C2C,B2C的电子商务模式也不断的成熟.这时催生出了众多电子商务相关的PHP开源产品.B2C方面有Ecshop ...

  3. EcShop二次开发学习方法和Ecshop二次开发必备基础

    ecshop二次开发学习方法 近年来,随着互联网的发展,电子商务也跟着一起成长,B2B,C2C,B2C的电子商务模式也不断的成熟.这时催生出了众多电子商务相关的php开源产品.B2C方面有Ecshop ...

  4. Zabbix二次开发_01基础

    最近有个想法:想做一个zabbix数据的二次呈现,所以来写一下Zabbix的api的内容. 先说下zabbix api的认证基础. Zabbix API简介 Zabbix API开始扮演着越来越重要的 ...

  5. Nopcommerce 二次开发2 Admin

    Admin 菜单 增加 siteMap.config增加一行 <siteMapNode SystemName="Hotels" nopResource="Admin ...

  6. Nopcommerce 二次开发2 WEB

    using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel.Syndica ...

  7. nopcommerce 二次开发

    http://www.cnblogs.com/nopcommerce-b2c/ http://www.nopchina.net/ 数据库结构 http://www.xcode.me/open/docu ...

  8. 最好最实用的PHP二次开发教程

    ◆二次开发 1.什么是二次开发? 二次开发,简单的说就是在现有的软件上进行定制修改,功能的扩展,然后达到自己想要的功能和效果,一般来说都不会改变原有系统的内核. 2.为什么要二次开发? 随着信息化技术 ...

  9. 数据层交换和高性能并发处理(开源ETL大数据治理工具--KETTLE使用及二次开发 )

    ETL是什么?为什么要使用ETL?KETTLE是什么?为什么要学KETTLE?        ETL是数据的抽取清洗转换加载的过程,是数据进入数据仓库进行大数据分析的载入过程,目前流行的数据进入仓库的 ...

随机推荐

  1. sql中not exists的用法

    例子:查询物料表(tbl_material)中存在,配件主数据表(tbl_part_base_info)中不存在的配件编号: select m.part_no from tbl_material m ...

  2. Flex 关闭浏览器

    在Actionscript 2及以前,要打开任何网址,只需调用全局函数getURL()即可.在Actionscript 3中,已经取消了getURL()这个全局函数,取而代之的是flash.net包中 ...

  3. Android开发教程:shape和selector的结合使用

    shape和selector是Android UI设计中经常用到的,比如我们要自定义一个圆角Button,点击Button有些效果的变化,就要用到shape和selector.可以这样说,shape和 ...

  4. android 底层入门开发(二)

    LED将为我闪烁:控制发光二极管 对于大多数Linux驱动来说,需要直接与硬件交互,本章主要介绍用Linux驱动来控制二极管的明暗,即通过Linux驱动发送数据控制开发板上LED灯的开关. 第一节介绍 ...

  5. mouseover事件与mouseenter事件的区别

    不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件.对应mouseout 只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件.对应mouseleave 被触发的 M ...

  6. [转]Linux命令的返回值

    Linux命令的返回值 对于某些监测脚本和探测命令蛮有用的: 在 Linux 下,不管你是启动一个桌面程序也好,还是在控制台下运行命令,所有的程序在结束时,都会返回一个数字值,这个值叫做返回值,或者称 ...

  7. Lua 调用 Opencv 的方法

    Lua 调用 Opencv 的方法 最近想用 Lua 调用 Opencv 进行相关像素级操作,如:bitwise_and 或者 bitwise_or,从而完成图像 IoU 的计算. 那么,怎么用 Lu ...

  8. memcache原理、简单使用、分布式实现方案

    原理:http://www.cnblogs.com/chy2055/p/5127499.html 使用教程:http://www.travisup.com/post/index/21 memcache ...

  9. SQL Server 连接字符串备忘

    今天把服务器上的远程访问关了,把连接字符串中的IP地址改成了.,然后就一直连不上.弄了半天,原来是本地连接时非默认实例,不能带端口号. 1.原来的连接服务器地址是:192.168.0.1SQL2005 ...

  10. linux yum命令详解-转

    yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理,能够从指定的服务器自动下载RP ...