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是数据的抽取清洗转换加载的过程,是数据进入数据仓库进行大数据分析的载入过程,目前流行的数据进入仓库的 ...
随机推荐
- Android Studio的简单设置:
4.关闭更新: 如下图所示: 6.添加api文档悬浮提示: AS默认是没有api文档悬浮提示的,只有按住[Ctrl+Q]太会出现提示.如果要添加api的自动悬浮提示,设置如下: 上图中,在红框部分打钩 ...
- iOS开发之cell多按钮
iOS开发经常出现cell需要多个按钮,一般以为要导入第三方框架.但其实iOS 8以后,系统提供了UITableViewRowAction以及新的delegate方法,使得自定义一些操作变得非常容易. ...
- 【Cocos2d-x 3.x】 动作类Action源码分析
游戏设计中,动作是不可缺少的,Cocos2d-x中所有的动作都继承自Action类,而Action类继承自Ref和Clonable类,整个动作类继承体系如图: FiniteTimeAction是所有瞬 ...
- jsp按钮隐藏自动点击
<%@ page language="java" import="java.util.*" pageEncoding="big5"%& ...
- LeetCode() Symmetric Tree
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...
- win32程序通过LPCREATESTRUCT中的lpCreateParams传递参数给窗口过程函数
win32窗口程序中如果需要给窗口过程函数传递自定义参数,可以通过LPCREATESTRUCT结构体中的lpCreateParams进行传递. 创建窗口实例函数: m_hWnd = CreateWin ...
- WIN7下搭建CORDOVA环境
Cordova 环境搭建 1安装JDK 工具文件夹中:jdk目录 1)下载地址:http://www.oracle.com/technetwork/java/javase/downloads/inde ...
- Makefile简易教程
本文部分内容引用: 中文维基百科. 一个简单的Makefile教程. Makefile简介 在软件开发中,make通常被视为一种软件构建工具.该工具主要经由读取一种名为"makefile&q ...
- [PHP] - Apache + PHP 环境搭建
Apache和PHP的版本分别为: httpd-2.4.9-win64-VC11.zip php-5.6.9-Win32-VC11-x64.zip 下载地址: php-5.6.9-Win32-VC11 ...
- 认识UML类图元素
在Visio里,包和类的关系是包含关系,将类拖入包的文件夹之后,关系就建立了,二元关联符号可以设置为:聚合.合成.接口:空心圆+直线(唐老鸭类实现了‘讲人话’):依赖:虚线+箭头(动物和空气的关系): ...