基本信息
源码名称:bootstrap+MVC5+EF6 最新框架通用项目完整源码(XX,含数据库)下载
源码大小:19.85M
文件格式:.zip
开发语言:C#
更新时间:2014-10-16
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 20 元×
微信扫码支付:20 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
里面含有 上传图片、分页、add用户、日志记录 等例子
里面含有 上传图片、分页、add用户、日志记录 等例子
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Web; using System.Web.Mvc; using System.Web.Routing; using Dev.Comm.Web.Mvc.Pager; using Dev.Framework.FileServer; using XX.Data.Models; using XX.Services; namespace XX.Web.Controllers { public class TestController : Controller { private readonly Lazy<ITestUserService> _testuserService; public TestController(Lazy<ITestUserService> testuserService) { _testuserService = testuserService; } // // GET: /Test/ public ActionResult Index(string key, int page=1) { const int pageSize = 10; int totalCount = 0; List<testuser> list = _testuserService.Value.GetTestUserList(key, page, pageSize, out totalCount); this.ViewBag.totalCount = totalCount; var routeValueDictionary = new System.Web.Routing.RouteValueDictionary(); if (!string.IsNullOrEmpty(key)) routeValueDictionary.Add("key", key); //routeValueDictionary.Add("pagesize", pageSize); //if (xxx != null) RouteValueDictionary.Add("xxx", xxx); var pager = new Pagination(page, totalCount, pageSize, "Index", "Test", routeValueDictionary, "page"); ViewBag.pager = pager; Dev.Log.Loger.Info("search:testindex_" page.ToString()); return View(list); } public ActionResult Show() { return View(); } public ActionResult AddTestUser() { return View(); } [HttpPost] public ActionResult AddTestUser(testuser model) { var uid = this._testuserService.Value.CheckUserName(model.username); if (uid != -1) return Content("已存在"); var result = this._testuserService.Value.AddTestUser(model); Dev.Log.Loger.Debug("create:" model.username); if (result) { return Content("成功"); } else { return Content("失败"); } //return View(); } public async Task<ActionResult> GetAllASync() { var users = await this._testuserService.Value.GetAllTestUserASync(); return View(users); } //public ActionResult AddTestUserASync() //{ // return View(); //} //[HttpPost] //public async Task<ContentResult> AddTestUserASync(testuser model) //{ // var typeid = await this._testuserService.Value.CheckUserNameAsync(model.username); // //model.Typeid = typeid; // var result = await this._testuserService.Value.AddTestUserAsync(model); // if (result) // { // return Content("成功"); // } // else // { // return Content("失败"); // } // //return View(); //} public ActionResult Upload() { return View(); } [HttpPost] public ActionResult Upload(HttpPostedFileBase imgFile, string dirName = "image") { //HttpPostedFileBase imgFilexx = this.HttpContext.Request.Files["imgFile"]; String fileUrl = ""; string fileKey = ""; var docFile = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IDocFile>(); ; var imageFile = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IImageFile>(); ; var key = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IKey>(); ; ; if (dirName == "image") { fileKey = imageFile.SaveImageFile(imgFile.InputStream, imgFile.FileName); fileUrl = key.GetFileUrl(fileKey); } else { fileKey = docFile.Save(imgFile.InputStream, imgFile.FileName); fileUrl = key.GetFileUrl(fileKey); } return Content("操作成功:\r\n" fileKey "\r\n" fileUrl); } } }