public override async Task Generate(CommandLineGeneratorModel controllerGeneratorModel) { if (!string.IsNullOrEmpty(controllerGeneratorModel.ControllerName)) { if (!controllerGeneratorModel.ControllerName.EndsWith(Constants.ControllerSuffix, StringComparison.Ordinal)) { controllerGeneratorModel.ControllerName = controllerGeneratorModel.ControllerName + Constants.ControllerSuffix; } } else { throw new ArgumentException(GetRequiredNameError); } ValidateNameSpaceName(controllerGeneratorModel); var layoutDependencyInstaller = ActivatorUtilities.CreateInstance <MvcLayoutDependencyInstaller>(ServiceProvider); await layoutDependencyInstaller.Execute(); var namespaceName = string.IsNullOrEmpty(controllerGeneratorModel.ControllerNamespace) ? GetDefaultControllerNamespace(controllerGeneratorModel.RelativeFolderPath) : controllerGeneratorModel.ControllerNamespace; var templateModel = new ClassNameModel(className: controllerGeneratorModel.ControllerName, namespaceName: namespaceName); var outputPath = ValidateAndGetOutputPath(controllerGeneratorModel); await CodeGeneratorActionsService.AddFileFromTemplateAsync(outputPath, GetTemplateName(controllerGeneratorModel), TemplateFolders, templateModel); Logger.LogMessage(string.Format(MessageStrings.AddedController, outputPath.Substring(ApplicationInfo.ApplicationBasePath.Length))); await layoutDependencyInstaller.InstallDependencies(); }
public override async Task Generate(CommandLineGeneratorModel controllerGeneratorModel) { if (!string.IsNullOrEmpty(controllerGeneratorModel.ControllerName)) { if (!controllerGeneratorModel.ControllerName.EndsWith(Constants.ControllerSuffix, StringComparison.Ordinal)) { controllerGeneratorModel.ControllerName = controllerGeneratorModel.ControllerName + Constants.ControllerSuffix; } } else { throw new ArgumentException("Controller name is required for an Empty Controller"); } var layoutDependencyInstaller = ActivatorUtilities.CreateInstance <MvcLayoutDependencyInstaller>(ServiceProvider); await layoutDependencyInstaller.Execute(); var templateModel = new ClassNameModel(className: controllerGeneratorModel.ControllerName, namespaceName: GetControllerNamespace()); var templateName = "EmptyController.cshtml"; var outputPath = ValidateAndGetOutputPath(controllerGeneratorModel); await CodeGeneratorActionsService.AddFileFromTemplateAsync(outputPath, templateName, TemplateFolders, templateModel); Logger.LogMessage("Added Controller : " + outputPath.Substring(ApplicationEnvironment.ApplicationBasePath.Length)); await layoutDependencyInstaller.InstallDependencies(); }
public override async Task Generate(CommandLineGeneratorModel controllerGeneratorModel) { if (!string.IsNullOrEmpty(controllerGeneratorModel.ControllerName)) { if (!controllerGeneratorModel.ControllerName.EndsWith(Constants.ControllerSuffix, StringComparison.Ordinal)) { controllerGeneratorModel.ControllerName = controllerGeneratorModel.ControllerName + Constants.ControllerSuffix; } } else { throw new ArgumentException(GetRequiredNameError); } var layoutDependencyInstaller = ActivatorUtilities.CreateInstance<MvcLayoutDependencyInstaller>(ServiceProvider); await layoutDependencyInstaller.Execute(); var templateModel = new ClassNameModel(className: controllerGeneratorModel.ControllerName, namespaceName: GetControllerNamespace()); var outputPath = ValidateAndGetOutputPath(controllerGeneratorModel); await CodeGeneratorActionsService.AddFileFromTemplateAsync(outputPath, GetTemplateName(controllerGeneratorModel), TemplateFolders, templateModel); Logger.LogMessage("Added Controller : " + outputPath.Substring(ApplicationEnvironment.ApplicationBasePath.Length)); await layoutDependencyInstaller.InstallDependencies(); }
public ActionResult RioPicView(int?page) { string ID = string.Empty; string title = "PicView"; string mode = "V"; bool isUser = false; if (Request.QueryString.Get("m") != null) { if (Request.QueryString.Get("m").Equals("E")) { title = "PicEdit"; mode = "E"; } } ViewBag.title = title; ClassNameModel cn = ClassNameModel.getClassName("pic"); ViewBag.className = cn; #region getData List <Rio_Pic> data = new List <Rio_Pic>(); if (Session["UserID"] != null) { ID = Session["UserID"].ToString(); data = PicModel.getUserAllPicByID(ID); } if (Request.QueryString.Get("vid") != null) { ID = Request.QueryString.Get("vid"); data = PicModel.getUserPicEnableByID(ID); } if (Session["UserID"] != null && Request.QueryString.Get("vid") != null) { if (Session["UserID"].ToString().Equals(Request.QueryString.Get("vid"))) { ID = Session["UserID"].ToString(); isUser = true; data = PicModel.getUserAllPicByID(ID); } } if (Session["UserID"] == null && Request.QueryString.Get("vid") == null) { return(RedirectToAction("Login", "Rio_Account", null)); } var pageNumeber = page ?? 1; var pageData = data.ToPagedList(pageNumeber, pageSize); ViewBag.vid = ID; ViewBag.mode = mode; ViewBag.isUser = isUser; #endregion return(View(pageData)); }
public ActionResult CompressionView(int?page) { int pageSize = 20; int userSN = 0; bool isUser = false; string ID = string.Empty; string mode = "V"; string title = "CompressionView"; List <Rio_Compression> data = new List <Rio_Compression>(); if (Request.QueryString.Get("m") != null) { if (Request.QueryString.Get("m").Equals("E")) { title = "CompressionEdit"; mode = "E"; } } if (Session["UserID"] != null) { int.TryParse(Session["UserSN"].ToString(), out userSN); data = CompressionModel.getCompressionByUserSN(userSN); } if (Request.QueryString.Get("vid") != null) { ID = Request.QueryString.Get("vid"); userSN = AccountModel.getAccountByID(ID).SN; data = CompressionModel.getCompressionClientByUserSN(userSN); } if (Request.QueryString.Get("vid") != null && Session["UserID"] != null) { if (Request.QueryString.Get("vid") == Session["UserID"].ToString()) { int.TryParse(Session["UserSN"].ToString(), out userSN); data = CompressionModel.getCompressionByUserSN(userSN); isUser = true; } } if (Session["UserID"] == null && Request.QueryString.Get("vid") == null) { return(RedirectToAction("Login", "Rio_Account", null)); } ViewBag.vid = ID; ViewBag.mode = mode; ViewBag.title = title; ViewBag.isUser = isUser; ViewBag.className = ClassNameModel.getClassName("compression"); var pageNumeber = page ?? 1; var pageData = data.ToPagedList(pageNumeber, pageSize); return(View(pageData)); }
public ActionResult RioDocView(int?page) { int pageNumber = page ?? 1; string ID = string.Empty; string title = "DocView"; string mode = "V"; bool isUser = false; List <Rio_Doc> data = new List <Rio_Doc>(); ClassNameModel cn = ClassNameModel.getClassName("doc"); if (Request.QueryString.Get("m") != null) { if (Request.QueryString.Get("m").Equals("E")) { title = "DocEdit"; mode = "E"; } } ViewBag.title = title; if (Session["UserID"] != null) { ID = Session["UserID"].ToString(); data = DocModel.getUserAllDocByID(ID); } if (Request.QueryString.Get("vid") != null) { ID = Request.QueryString.Get("vid").ToString(); data = DocModel.getUserDocEnableListByID(ID); } if (Session["UserID"] != null && Request.QueryString.Get("vid") != null) { if (Session["UserID"].ToString().Equals(Request.QueryString.Get("vid"))) { ID = Session["UserID"].ToString(); data = DocModel.getUserAllDocByID(ID); isUser = true; } } if (Session["UserID"] == null && Request.QueryString.Get("vid") == null) { return(RedirectToAction("Login", "Rio_Account", null)); } ViewBag.mode = mode; ViewBag.vid = ID; ViewBag.isUser = isUser; ViewBag.className = cn; var pageNumeber = page ?? 1; var pageData = data.ToPagedList(pageNumeber, 24); return(View(pageData)); }
public ControllerWithContextTemplateModel( [NotNull] ModelType modelType, [NotNull] string dbContextFullTypeName) { ModelType = modelType; var classNameModel = new ClassNameModel(dbContextFullTypeName); ContextTypeName = classNameModel.ClassName; DbContextNamespace = classNameModel.NamespaceName; }
public async Task GenerateAsync(MvcModel model) { logger.LogMessage("creating controller"); model.ControllerName = string.Concat(model.ModelClass, Constants.ControllerSuffix); logger.LogMessage("creating model controller"); var templateModel = new ClassNameModel(className: model.ControllerName, namespaceName: NameSpaceUtilities.GetSafeNameSpaceFromPath(applicationInfo.ApplicationBasePath)); logger.LogMessage("creating files"); var outputPath = ValidateAndGetOutputPath(model, string.Concat(model.ControllerName, Constants.CodeFileExtension)); await codeGeneratorActionsService.AddFileFromTemplateAsync(outputPath, Constants.EmptyControllerTemplate, TemplateFolders, templateModel); }
public RazorPageWithContextTemplateModel(ModelType modelType, string dbContextFullTypeName) { if (modelType == null) { throw new ArgumentNullException(nameof(modelType)); } if (dbContextFullTypeName == null) { throw new ArgumentNullException(nameof(dbContextFullTypeName)); } ModelType = modelType; var classNameModel = new ClassNameModel(dbContextFullTypeName); ContextTypeName = classNameModel.ClassName; DbContextNamespace = classNameModel.NamespaceName; }
public ActionResult RioAlbumView(int?page) { string ID = string.Empty; bool isUser = false; List <Vw_Album> data = new List <Vw_Album>(); if (Session["UserID"] != null) { ID = Session["UserID"].ToString(); data = AlbumModel.getUserAllVwAlbumList(ID).OrderByDescending(o => o.CreateDate).ToList(); } if (Request.QueryString.Get("vid") != null) { ID = Request.QueryString.Get("vid").ToString(); data = AlbumModel.getUsertVwAlbumEnableListByID(ID).OrderByDescending(o => o.CreateDate).ToList(); } if (Session["UserID"] != null && Request.QueryString.Get("vid") != null) { if (Session["UserID"].ToString().Equals(Request.QueryString.Get("vid"))) { ID = Session["UserID"].ToString(); data = AlbumModel.getUserAllVwAlbumList(ID).OrderByDescending(o => o.CreateDate).ToList(); isUser = true; } } if (Session["UserID"] == null && Request.QueryString.Get("vid") == null) { return(RedirectToAction("Login", "Rio_Account", null)); } ViewBag.vid = ID; ViewBag.isUser = isUser; var pageNumber = page ?? 1; var pageData = data.ToPagedList(pageNumber, 20); ViewBag.className = ClassNameModel.getClassName("albumView"); return(View(pageData)); }
public ActionResult RioAlbumContent(int?SN, int?page) { int aSN = SN ?? 0; int pageNumber = page ?? 1; string userID = string.Empty; bool isUser = false; Vw_Album va = new Vw_Album(); if (aSN == 0 || Request.QueryString.Get("vid") == null) { return(RedirectToAction("Login", "Rio_Account", null)); } if (Session["UserID"] != null) { userID = Session["UserID"].ToString(); } if (Request.QueryString.Get("vid").Equals(userID)) { isUser = true; } va = AlbumModel.getVwAlbum(aSN); if (isUser && va.IsEnable == false) { return(RedirectToAction("RioAlbumView", "Rio_Album", new { vid = Request.QueryString.Get("vid") })); } ViewBag.aSN = aSN; ViewBag.VwAlbum = va; ViewBag.isUser = isUser; ViewBag.vid = Request.QueryString.Get("vid"); ViewBag.className = ClassNameModel.getClassName("albumContent"); ViewBag.getJoinPic = AlbumJoinPicModel.getUpdateJoinPic(aSN).ToPagedList(pageNumber, 20); return(View(db.Rio_Album.ToList())); }
private async Task GenerateEmptyController(ControllerGeneratorModel controllerGeneratorModel, string controllerNamespace) { if (!string.IsNullOrEmpty(controllerGeneratorModel.ControllerName)) { if (!controllerGeneratorModel.ControllerName.EndsWith(Constants.ControllerSuffix, StringComparison.Ordinal)) { controllerGeneratorModel.ControllerName = controllerGeneratorModel.ControllerName + Constants.ControllerSuffix; } } else { throw new ArgumentException("Controller name is required for an Empty Controller"); } var templateModel = new ClassNameModel() { ClassName = controllerGeneratorModel.ControllerName, NamespaceName = controllerNamespace }; var templateName = "EmptyController.cshtml"; var outputPath = ValidateAndGetOutputPath(controllerGeneratorModel); await _codeGeneratorActionsService.AddFileFromTemplateAsync(outputPath, templateName, TemplateFolders, templateModel); _logger.LogMessage("Added Controller : " + outputPath.Substring(_applicationEnvironment.ApplicationBasePath.Length)); }