public ActionResult Delete(int appKey) { AppInfo app = repo.GetAppInfo(appKey); if (app == null) { ViewBag.ErrorMessage = "找不到指定的应用!"; return View(); } AppModel model = new AppModel { AppKey = app.appkey, AppSecret = app.appsecret, RedirectUri = app.redirecturi, Name = app.name, Description = app.description, Owner = app.owner }; string userName = repo.GetUsersDetail(app.owner).Name; ViewBag.UserName = userName; return View(model); }
public ActionResult Create(AppModel appModel) { if (ModelState.IsValid) { AppInfo newApp = new AppInfo { appsecret = RandomString.RandomStringImpl.CreateRandomString(20), name = appModel.Name, description = appModel.Description, redirecturi = appModel.RedirectUri, owner = GetUserId() }; if (repo.CreateApp(newApp)) { AppInfo theApp = repo.GetAppInfo(newApp.name); return RedirectToAction("Detail", "App", new { appKey = theApp.appkey }); } ViewBag.ErrorMessage = "对不起,这个应用已经有人申请过了!请换个名字试试"; } ViewBag.UserName = repo.GetUsersDetail(GetUserId()).Name; return View(appModel); }
public ActionResult Modify(AppModel model) { if (ModelState.IsValid) { AppInfo newAppInfo = new AppInfo { appsecret = model.AppSecret, owner = model.Owner, name = model.Name, redirecturi = model.RedirectUri, description = model.Description }; if (repo.UpdateApp(model.AppKey, newAppInfo)) return RedirectToAction("Detail", new { appKey = model.AppKey }); ModelState.AddModelError("", "Update Failed"); ViewBag.ErrorMessage = "你所使用的应用名称已被使用,请换一个试试!"; } ViewBag.UserName = repo.GetUsersDetail(GetUserId()).Name; return View(model); }