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是数据的抽取清洗转换加载的过程,是数据进入数据仓库进行大数据分析的载入过程,目前流行的数据进入仓库的 ...
随机推荐
- php部分---PDO;
PDO数据访问抽象层 PDO的三个功能: 1.操作其它数据库2.事务功能3.防止SQL注入攻击 操作数据库: 造PDO对象 //$dsn = "mysql:dbname=mydb;host= ...
- Scala笔记整理
使用类型参数化数组(Array) 创建java.math.BigInteger实例: var big = new java .math.BigInteget("12345678") ...
- python 模拟用户登录代码
需求:输入用户名,判断用户是否被锁定,锁定则退出,否则进入密码验证,输入三次错误密码之后此用户被锁定. userlist.txt里,用":"将用户名.密码.状态码分开: [root ...
- POJ1986 Distance Queries (LCA)(倍增)
Distance Queries Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 12950 Accepted: 4577 ...
- LEETCODE —— Surrounded Regions
Total Accepted: 43584 Total Submissions: 284350 Difficulty: Medium Given a 2D board containing 'X' a ...
- redis 3.2.6 on ubuntu 14.04
1. official site: https://github.com/antirez/redis/releases 2. compile and setup tar zxf redis-3.2.6 ...
- Sql server 备份还原后出现“受限制用户”问题
http://jingyan.baidu.com/article/eb9f7b6dcbf1ea869264e856.html SQL数据库作备份和还原操作几乎是日常性事务了.但某次在对Sql Serv ...
- kylin(一): 原理架构
由eBay开源的一个大数据OLAP框架,2014年11月加入了Apache,项目名字也改成了"Apache Kylin",Apache Kylin是唯一来自中国的Apache顶级开 ...
- BRISK: Binary Robust Invariant Scalable Keypoints
注意:本文含有一些数学公式,如果chrome不能看见公式的话请用IE打开网站 1.特征点提取 特征点提取有以下几个步骤: a.尺度空间金字塔结构的构造 和SIFT类似,尺度空间金字塔是由不同的尺度 ...
- Linux 随机生成随机数
#!/bin/bash echo $(($RANDOM % 39)) 表示生成0-39的随机数 并且不为0和39