据我了解,MVC 框架非常庞大(Zend、Cake、CodeIngniter),因此谈论可扩展性并建议使用 MVC 似乎几乎是相反的。
我有一个控制器,可以获取要传递给视图的数据.向此注入(通过疙瘩容器)服务,该服务使用许多域模型+业务逻辑来创建数据.
服务本身有一个注入其中的"存储库"类,它有创建数据映射器和返回域模型实例的方法.
我知道我可能没有深入了解存储库概念,因为Martin Fowler将其设置为"在映射层上构建另一层抽象"和"存储库在域和数据映射层之间进行调解,就像在-memory域对象集合." 所以我可能会错误地使用这个术语.
服务:
class InputService
{
private $repos;
public function __construct($repo) {
$this->repos = $repo;
}
public function getInitialData()
{
$product = $this->repo->getProduct();
$country = $this->repo->getCountry();
$spinalPoint = $this->repo->getPoint();
/*business logic with model instances to produce data array*/
return //array of data
}
}
Run Code Online (Sandbox Code Playgroud)
库:
class InputRepository
{
private $db;
public function __construct($db) {
$this->db = $db;
}
public function getCountry()
{
$mapper = new CountryMapper($this->db);
$country = $mapper->fetch();
return $country; //returns country object
} …Run Code Online (Sandbox Code Playgroud) php model-view-controller datamapper decoupling repository-pattern
我想检索Azure门户上资源中存在的所有数据。我发现,有一个REST API可以帮助您检索数据,以了解应用程序。我想要的是获取数据并在我的网页上生成一个网格报告,该报告显示事件相关信息,即日期,类型,消息和所有相关信息。我以前从未使用过REST API,而我想要的帮助是在Visual Studio中基于MVC的Web项目中使用此REST API的正确指南。如果任何人都可以帮助将是极大的帮助。
c# model-view-controller asp.net-mvc azure-application-insights visual-studio-2015
我有一个字符串
http://localhost:1114/api/Upload/GetFile?uploadFile=/Uploads/SupportingDocuments/ca2432cc-a9a3-4b98-b27a-7fadf9bb524bNC%20#1%20-%20MAIL%20TO%20ACCREDITATION%20BODY%20DAC.pdf
Run Code Online (Sandbox Code Playgroud)
文件名有charecter hash标签'#',我在调试控制器接收后找到了它
/Uploads/SupportingDocuments/ca2432cc-a9a3-4b98-b27a-7fadf9bb524bNC
Run Code Online (Sandbox Code Playgroud)
作为文件名,但是如果我删除它,那么它会收到正确的文件名.我有很多带有这个文件名的文件
ca2432cc-a9a3-4b98-b27a-7fadf9bb524bNC #1 - MAIL.pdf
Run Code Online (Sandbox Code Playgroud)
那么如何使用api调用也可以在c#中使用这个字符
[HttpGet]
[Route("GetFile")]
public IHttpActionResult GetFile(string uploadFile)
{
//without # works only need solution
}
Run Code Online (Sandbox Code Playgroud) <?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="connect_cbu" connectionString="Data Source=192.168.66.67; Initial Catalog=CBU; Persist Security Info=True; User ID=Admin;Password=1234"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)
假设我定义了以下两个字符串:public static string user;and public static string pass;inside Global.cs.有可能以某种方式将它们包括在内connectionString吗?
例:
connectionString="Data Source=192.168.66.67; Initial Catalog=CBU; Persist Security Info=True; User ID='Global.user';Password='Global.pass'"/>
Run Code Online (Sandbox Code Playgroud)
解决方案,基于TheGeneral的答案:
的app.config
<connectionStrings>
<clear/>
<add name="connect_cbu" connectionString="Data Source=192.168.66.67; Initial Catalog=CBU; Persist Security Info=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
MainWindow.xaml.cs
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Windows;
namespace Test
{
public partial class …Run Code Online (Sandbox Code Playgroud) 我有一个疑问是有可能有一个单一的表单(查看页面),有多个动作,如我想在同一个视图页面上保存,更新和删除..如果用户点击任何按钮,那么它必须调用一个必要的控制器功能是否可能?
我试图在我的网站上创建一个民意调查功能.如果用户在按下按钮时尚未投票,并且如果用户在按下按钮时已经投票,则向下按1,我希望计数增加1.现在它只是上升到无穷大,永远不会-1.
如果我将if(已投票)更改为if(!voteed),则会发生相反的问题,并且每次点击都会变为-1.
var voted = new Boolean(false);
$(document).ready(function () {
$("#container div button").click(function () {
if (voted) {
$(this).parent().animate({
width: '+=100px'
}, 500);
$(this).prev().html(parseInt($(this).prev().html()) + 1)
voted === true;
} else {
$(this).parent().animate({
width: '-=100px'
}, 500);
$(this).prev().html(parseInt($(this).prev().html()) - 1)
voted === false;
}
});
});
Run Code Online (Sandbox Code Playgroud) 尽管我用谷歌搜索了一段时间,但我找不到服务器端Blazor的任何Model-View-XYZ框架实现,即Razor组件(XYZ代表以下任何一种:Controller,Presenter,ViewModel)。
如果有人知道这样的实现,无论它处于开发的哪个阶段,请告诉我。非常感谢。
编辑:问题是,是否有人遇到或参与了这种框架的开发。
这个问题非常简单 -有人在Internet上遇到过一些有关针对Razor组件(又称为服务器端Blazor)的框架的信息,因为到目前为止我还没有。
给了我这段代码,它有一个带两组大括号的If语句。我假设这是一个if else语句,但是没有“ else”
if (Value.Contains("WMD ESA"))
{
UsersInfo.Add(Benefit.ToString());
}
{
UsersInfo.Add(((decimal)Benefit.Amount().ToString());
}
Run Code Online (Sandbox Code Playgroud)
根据我的断点,它运行正常,没有任何错误,所以我不确定。
我正在尝试从控制器向视图发送数据集合。我设法使我的代码与单个集合一起工作。是否可以通过多个集合(不使用ViewBag而是将这些作为参数传递给View)来实现?
我试过的
控制者
public ActionResult Index()
{
Dictionary<int, string> DictOne = MyObjOne.DictOne;
Dictionary<int, string> DictTwo= MyObjTwo.DictTwo;
return View(new { DictOne, DictTwo });
}
Run Code Online (Sandbox Code Playgroud)
我所拥有的(已经在工作):
控制者
public ActionResult Index()
{
Dictionary<int, string> DictOne = MyObjOne.DictOne;
return View(DictOne);
}
Run Code Online (Sandbox Code Playgroud)
视图
@model Dictionary<int, string>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<span class="glyphicon glyphicon-th-list"></span>
Test
</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th>
Test
</th>
</tr>
</thead>
<tbody>
@foreach (KeyValuePair<int, string> kvp in Model)
{
<tr>
<td>
@kvp.Value
</td>
</tr>
} …Run Code Online (Sandbox Code Playgroud) c# ×5
asp.net-mvc ×2
php ×2
.net ×1
api ×1
asp.net ×1
blazor ×1
codeigniter ×1
datamapper ×1
decoupling ×1
forms ×1
frameworks ×1
javascript ×1
mvp ×1
mvvm ×1
razor ×1
view ×1
wpf ×1