基本信息
源码名称:QuickBootstrap mvc EF Bootstrap 快速开发框架源码
源码大小:0.76M
文件格式:.zip
开发语言:C#
更新时间:2014-10-23
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
基于ASP.NET MVC、EntityFramework、Memcached、Bootstrap的快速项目开发框架,只需3秒钟即可创建一个带有简单用户管理的项目。
using System;
using System.Web.Mvc;
using QuickBootstrap.Entities;
using QuickBootstrap.Extendsions;
using QuickBootstrap.Filters;
using QuickBootstrap.Models;
using QuickBootstrap.Services;
using QuickBootstrap.Services.Impl;
using QuickBootstrap.Services.Util;
namespace QuickBootstrap.Controllers
{
[UserAuthorization]
public class UserManageController : Controller
{
#region 私有字段
private readonly IUserManageService _userManageService = new UserManageService();
private readonly IDepartmentService _departmentService = new DepartmentService();
private readonly IRoleService _roleService = new RoleService();
#endregion
#region action method
public ActionResult Index(int pageIndex = 0, int pageSize = 20)
{
var paging = new Paging { PageIndex = pageIndex, PageSize = pageSize };
return View(_userManageService.GetList(paging));
}
public ActionResult Create()
{
BindSelectListDataSource();
var viewModel = new UserCreateRequest {IsEnable = true};
return View(viewModel);
}
[HttpPost]
public ActionResult Create(UserCreateRequest model)
{
if (ModelState.IsValid == false)
{
BindSelectListDataSource();
return View(model);
}
if (_userManageService.ExistsUser(model.UserName) == false)
{
_userManageService.Create(new User
{
UserName = model.UserName,
UserPwd = model.Password.ToMd5(),
Nick = model.Nick,
CreateTime = DateTime.Now,
IsEnable = model.IsEnable,
DepartmentId = model.DepartmentId,
RoleId = model.RoleId
});
return RedirectToAction("Index");
}
ModelState.AddModelError("_error", "登录账号已存在");
BindSelectListDataSource();
return View(model);
}
public ActionResult Delete(string username = "")
{
if (username.Length > 0)
{
_userManageService.Delete(username);
}
return RedirectToAction("Index");
}
#endregion
#region 私有方法
private void BindSelectListDataSource()
{
ViewBag.RoleList = new SelectList(_roleService.GetAllList(), "Id", "Title");
ViewBag.DepartmentList = new SelectList(_departmentService.GetAllList(), "Id", "Title");
}
#endregion
}
}