Nopcommerce 二次开发1 基础
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 基础的更多相关文章
- Nopcommerce 二次开发0
Nopcommerce 是国外的一个高质量的开源b2c网站系统,基于EntityFramework6.0和MVC5.0,使用Razor模板引擎,有很强的插件机制,包括支付配送功能都是通过插件来实现的 ...
- Ecshop二次开发必备基础
EcShop二次开发学习方法 近年来,随着互联网的发展,电子商务也跟着一起成长,B2B,C2C,B2C的电子商务模式也不断的成熟.这时催生出了众多电子商务相关的PHP开源产品.B2C方面有Ecshop ...
- EcShop二次开发学习方法和Ecshop二次开发必备基础
ecshop二次开发学习方法 近年来,随着互联网的发展,电子商务也跟着一起成长,B2B,C2C,B2C的电子商务模式也不断的成熟.这时催生出了众多电子商务相关的php开源产品.B2C方面有Ecshop ...
- Zabbix二次开发_01基础
最近有个想法:想做一个zabbix数据的二次呈现,所以来写一下Zabbix的api的内容. 先说下zabbix api的认证基础. Zabbix API简介 Zabbix API开始扮演着越来越重要的 ...
- Nopcommerce 二次开发2 Admin
Admin 菜单 增加 siteMap.config增加一行 <siteMapNode SystemName="Hotels" nopResource="Admin ...
- Nopcommerce 二次开发2 WEB
using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel.Syndica ...
- nopcommerce 二次开发
http://www.cnblogs.com/nopcommerce-b2c/ http://www.nopchina.net/ 数据库结构 http://www.xcode.me/open/docu ...
- 最好最实用的PHP二次开发教程
◆二次开发 1.什么是二次开发? 二次开发,简单的说就是在现有的软件上进行定制修改,功能的扩展,然后达到自己想要的功能和效果,一般来说都不会改变原有系统的内核. 2.为什么要二次开发? 随着信息化技术 ...
- 数据层交换和高性能并发处理(开源ETL大数据治理工具--KETTLE使用及二次开发 )
ETL是什么?为什么要使用ETL?KETTLE是什么?为什么要学KETTLE? ETL是数据的抽取清洗转换加载的过程,是数据进入数据仓库进行大数据分析的载入过程,目前流行的数据进入仓库的 ...
随机推荐
- 初识Linux—1
1,Ctrl+C作用是终止当前的命令 2,ps显示目前正在执行的程序(命令)(process status) 3,退出是exit,连续按exit,最终会关闭终端 4,Root是管理员,其他的用户都是由 ...
- mysql 联合索引和唯一索引
一般来说.如果有where a=? and b=? and c=? 的语句. 如果表也有DML, 我一般只在a 上建索引. 这也是代价平衡的结果. 一方面 只在a 上建索引那么是 index ran ...
- 项目集成ReactiveCocoa遇到的坑及解决办法
首先,使用CocoaPods集成(注意:由于ReactiveCocoa需要iOS8.0,并且是与swift混编的,所以Podfile文件要写成platform :ios, '8.0' 和 use_fr ...
- 【转载】浅谈游戏开发之2D手游工具
浅谈游戏开发之2D手游工具 来源:http://www.gameres.com/459713.html 游戏程序 平台类型: iOS Android 程序设计: 其它 编程语言: 引擎/SDK ...
- WebService 不依赖配置文件直接在构造函数配置地址
研究了下 ClientBase(Binding binding, EndpointAddress remoteAddress) 这个重载更好用,都不用填名称比如 new PAS.WebService. ...
- appium 环境搭建 java
1 安装node.js 1.1 安装node.js http://nodejs.cn/download/ 1.2.下载后直接点击exe,按照提示一步一步的安装 1.3 安装成功后,运行cmd,输入no ...
- [转]权限问题导致Nginx 403 Forbidden错误的解决方法
权限问题导致Nginx 403 Forbidden错误的解决方法 投稿:junjie 字体:[增加 减小] 类型:转载 时间:2014-08-22 这篇文章主要介绍了权限问题导致Nginx 403 F ...
- mongoDB之Pipeline Aggregation Stages
原文链接:https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/ 管道聚合 $project Reshapes ...
- jquey easyui 常用方法
jquey easyui 常用方法 2015-05-31 13:02 4473人阅读 评论(0) 收藏 举报 版本:1.4.2 一.easyui -textbox: 1.去空格: $('#tt1'). ...
- SQL Server 优化-执行计划
对于SQL Server的优化来说,优化查询可能是很常见的事情.由于数据库的优化,本身也是一个涉及面比较的广的话题, 因此本文只谈优化查询时如何看懂SQL Server查询计划.毕竟我对SQL Ser ...