/// <summary> /// 创建餐厅 /// </summary> /// <param name="model"></param> /// <returns></returns> public IReturn Add(AddSupplierModel model) { M.Supplier supplier = model.ToSupplier(); if (supplier.Validate()) { M.RepositoryRegistry.Supplier.Add(supplier); return(this.WriteAndPublishDomainEvent <M.Supplier, AddDomainEvent>("Add", supplier, new AddDomainEvent(supplier.Id, supplier.Name, supplier.Tel, supplier.Address, supplier.CreateDate))); } return(this.Write("Add", supplier)); }
/// <summary> /// 更新餐厅信息 /// </summary> /// <param name="supplierId">餐厅ID</param> /// <param name="model">餐厅信息</param> /// <returns></returns> public IReturn Update(int supplierId, AddSupplierModel model) { M.Supplier supplier = M.RepositoryRegistry.Supplier.FindBy(supplierId); if (supplier != null) { model.ToSupplier(supplier); if (supplier.Validate()) { M.RepositoryRegistry.Supplier.Update(supplier); } } return(this.Write("Update", supplier)); }