public static MvcApplication Build(string applicationName) { var domain = Thread.GetDomain(); var assemblyName = new AssemblyName(applicationName); var assemblyBuilder = domain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave); var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, string.Format("{0}.dll", assemblyName.Name)); var mvcApplication = new MvcApplication(moduleBuilder); return mvcApplication; }
public static IMvcApplication UseMvc(this HttpServerSimulator server, ControllerContainer controllerContainer, IContentProvider contentProvider) { if (controllerContainer == null) throw new ArgumentNullException("controllerContainer"); if (contentProvider == null) throw new ArgumentNullException("contentProvider"); var mvcApplication = new MvcApplication(controllerContainer, contentProvider); UseMvc(server, mvcApplication); return mvcApplication; }
internal static void Initialize(MvcApplication mvcApplication) { AppSettingsReader reader = new AppSettingsReader(); DashboardSettings settings = new DashboardSettings(); settings.SiteTitle = (string)reader.GetValue("SiteTitle", typeof(string)); settings.MonoscapeAccessKey = (string)reader.GetValue("MonoscapeAccessKey", typeof(string)); settings.MonoscapeSecretKey = (string)reader.GetValue("MonoscapeSecretKey", typeof(string)); settings.ApplicationGridEndPointURL = (string)reader.GetValue("ApplicationGridEndPointURL", typeof(string)); settings.FileServerEndPointURL = (string)reader.GetValue("FileServerEndPointURL", typeof(string)); settings.LoadBalancerEndPointURL = (string)reader.GetValue("LoadBalancerEndPointURL", typeof(string)); settings.CloudControllerEndPointURL = (string)reader.GetValue("CloudControllerEndPointURL", typeof(string)); settings.ApFileTransferSocketPort = (int)reader.GetValue("ApFileTransferSocketPort", typeof(int)); Settings.Initialize(settings); }
public ActionResult GraphByInterval(Guid id, TimelineInterval interval) { var toDate = MvcApplication.GetServerDateTime(); var fromDate = TimelineHelper.IntervalToStartDate(toDate, interval); var metricRepository = CurrentAccountDbContext.GetMetricRepository(); var metric = metricRepository.GetById(id); var metricHistoryRepository = CurrentAccountDbContext.GetMetricHistoryRepository(); var rows = metricHistoryRepository .GetByPeriod(metric.ComponentId, fromDate, toDate, new[] { metric.MetricTypeId }) .OrderBy(t => t.BeginDate) .ToArray(); var model = GetCounterGraphDataModel(metric.MetricType, rows); return(PartialView("GraphPartial", model)); }
public void ConnexionTest() { // -- Controlleur à tester -- // MvcApplication app = new MvcApplication(); var controller = new HomeController(); // -- Parametres de test -- // string compteTest = "99999", mot_de_passeTest = "admin"; // -- Execution de la méthode à tester -- // GBNotification donnee = GBConvert.To_Object <GBNotification>( ((controller.Connexion(compteTest, mot_de_passeTest) as JsonResult).Data as Dictionary <string, object>)["notification"] ); // -- Test du résultat -- // Assert.AreEqual(donnee.est_echec, false); }
//创建ID public ActionResult AddFromId() { WXX_FormID wfm = new WXX_FormID(); wfm.FormID = Request["FromID"].ToString(); wfm.AddTime = MvcApplication.GetT_time(); wfm.AddUserID = LoginUser.ID; wfm.CanUse = 0; wfm.StopTime = wfm.AddTime.AddDays(7); try { WXX_FormIDService.AddEntity(wfm); return(Json(new { ret = "ok" }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { ret = "err", str = e.ToString() }, JsonRequestBehavior.AllowGet)); } }
public ActionResult JsonListaLecturasResumen(string __a, string __c, string __d, string __e) { return(new ContentResult { Content = MvcApplication._Serialize( new NLectura().NListaLecturasResumen( new Request_Lectura_Historico() { local = Convert.ToInt32(__a), f_ini = Convert.ToString(__c), f_fin = Convert.ToString(__d), lista = Convert.ToString(__e) } ) , true), ContentType = "application/json" }); }
public void ProductInsertDoesNotMatchGet() { // Arrange var routes = new RouteCollection(); MvcApplication.RegisterRoutes(routes); // Act var context = new FakeHttpContext("~/Product/Insert", "GET", false, null); var routeData = routes.GetRouteData(context); // Assert if (routeData != null) { var matchedRoute = (NamedRoute)routeData.Route; Assert.AreNotEqual("ProductInsert", matchedRoute.Name); } }
public ActionResult Index(RowList value) { string request; Request.InputStream.Seek(0, SeekOrigin.Begin); using (var reader = new StreamReader(Request.InputStream)) { request = reader.ReadToEnd(); } var serializer = JsonSerializer.Create(MvcApplication.GetJsonSerializationSettings()); serializer.TypeNameHandling = TypeNameHandling.All; var xnodeRequest = serializer.Deserialize <RowList>(new JsonTextReader(new StringReader(request))); return(View()); }
public JsonResult Update_StaffOn(Bank obj) { using (Planner2Entities rrc_db = new Planner2Entities()) { Bank a = rrc_db.Banks.Find(obj.ID); bool result = false; a.BankName = obj.BankName ?? a.BankName; a.ChuTaiKhoan = obj.ChuTaiKhoan ?? a.ChuTaiKhoan; a.ChiNhanh = obj.ChiNhanh ?? a.ChiNhanh; a.SoTaiKhoan = obj.SoTaiKhoan ?? a.SoTaiKhoan; rrc_db.SaveChanges(); MvcApplication.ReloadSetting(); result = true; return(Json(new { result = result, data = a }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Show(List <int> optionResult) { var Departments = GetSession.QueryOver <Department>().Take(optionResult.Count).List(); for (int i = 0; i < optionResult.Count; i++) { GetSession.CreateSQLQuery( string.Format("Update {0}Department set Option{1}Count=Option{1}Count+1 where Id={2}", MvcApplication.Config("table.Prefix"), optionResult[i], Departments[i].Id ) ).ExecuteUpdate(); Session["optionResult" + DateTime.Now.Date.ToShortDateString()] = "done"; } return(RedirectToAction("DepartmentResult")); }
public ActionResult Edit(string configjson) { JsonResultData result = new JsonResultData(); try { int n = BLL.FW.BF_SYS_CONFIG.SetAllConfigs(configjson); result.IsSuccess = true; result.Message = "成功更新了" + n + "个配置"; MvcApplication.UpdateSystemConfigs(); } catch (Exception ex) { result.Message = ex.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult TransactionScope() { using (var t = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted })) { try { throw new Exception("Transaction killing exception of doom!"); t.Complete(); } catch (Exception e) { MvcApplication.LogException(e); // this still gets logged, because Exceptional ignores transaction scopes } } return(RedirectToAction("Exceptions", "Home")); }
public static SelectList GetPlantImportList() { IPlantBLL plantBll = MvcApplication.GetInstance <PlantBLL>(); IZaidmExNPPBKCBLL nppbkcBLL = MvcApplication.GetInstance <ZaidmExNPPBKCBLL>(); var nppbkcList = nppbkcBLL.GetAll().Where(x => x.IS_DELETED != true).Select(x => x.NPPBKC_ID).ToList(); List <T001W> plantIdList; plantIdList = plantBll.GetAllPlant(); plantIdList = plantIdList.Where( x => x.IS_DELETED != true && x.NPPBKC_IMPORT_ID != null && nppbkcList.Contains(x.NPPBKC_IMPORT_ID)) .OrderBy(x => x.WERKS) .ToList(); var selectItemSource = Mapper.Map <List <SelectItemModel> >(plantIdList); return(new SelectList(selectItemSource, "ValueField", "TextField")); }
//添加产品详细数据 public ActionResult AddBaoJiaoOne() { YXB_Baojia bj = new YXB_Baojia(); bj.AddTime = MvcApplication.GetT_time(); bj.DelFlag = delFlag; bj.ZhuangTai = 0; bj.CPname = Convert.ToInt64(Request["CPname"]); bj.CPXingHao = Convert.ToInt64(Request["CPXingHao"]); bj.CPShuLiang = Convert.ToDecimal(Request["CPShuLiang"]); bj.BaoJiaTop_id = Convert.ToInt64(Request["editID"]); bj.WIN = 0; bj.CPDengJiID = Convert.ToInt64(Request["CPDengji"]); bj.Remark = Request["Reamk"]; YXB_BaojiaService.AddEntity(bj); Common.MemcacheHelper.Set("Allstr", Convert.ToInt64(Common.MemcacheHelper.Get("Allstr")) + 1); return(GetysbBaojia(bj.BaoJiaTop_id)); }
public JsonResult ProcessAddRoleRequest(string myRoleName, bool myRoleStatus) { try { var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false })); } if (string.IsNullOrEmpty(myRoleName) || myRoleName.Length < 2) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Invalid Role Name" })); } var passObj = new RegRoleObj { Name = myRoleName, Status = myRoleStatus ? 1 : 0, AdminUserId = userData.UserId, }; var response = new PortalRoleManager().AddRole(passObj, userData.Username); if (response?.Status == null) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Error Occurred! Please try again later" })); } if (!response.Status.IsSuccessful) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = string.IsNullOrEmpty(response.Status.Message.FriendlyMessage) ? "Process Failed! Unable to add role" : response.Status.Message.FriendlyMessage })); } return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "" })); } catch (Exception ex) { UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Process Error Occurred! Please try again later" })); } }
public JsonResult ProcessAddClientUserRequest(RegClientUserObj model) { try { var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false })); } if (model.ClientId < 1 || model.UserId < 1) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Invalid User Selection" })); } model.AdminUserId = userData.UserId; if (!GenericVal.Validate(model, out var msg)) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = $"Validation Error Occurred! Detail: {msg}" })); } var response = ClientService.AddClientUser(model, userData.Username); if (response?.Status == null) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Error Occurred! Please try again later" })); } if (!response.Status.IsSuccessful) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = string.IsNullOrEmpty(response.Status.Message.TechnicalMessage) ? "Process Failed! Unable to add course of study" : response.Status.Message.TechnicalMessage })); } return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "" })); } catch (Exception ex) { UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Process Error Occurred! Please try again later" })); } }
private ProductObj getProductObj(int clientId, int prodId) { try { var userData = MvcApplication.GetUserData(User.Identity.Name); if (userData == null || userData.UserId < 1) { return(new ProductObj()); } if (userData.ClientProductList == null || !userData.ClientProductList.Any()) { return(new ProductObj()); } var clients = new List <ProductObj>(); foreach (var item in userData.ClientProductList) { if (item.ClientInfo.ClientId == clientId) { clients.AddRange(item.Products.Select(m => m.ProductInfo).ToList()); break; } } if (!clients.Any()) { return(new ProductObj()); } var product = clients.Find(c => c.ProductId == prodId && c.Status == 1); if (product == null || product.ProductId < 1) { return(new ProductObj()); } return(product); } catch (Exception ex) { UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(new ProductObj()); } }
public static decimal GetretiredAmountByRequisitionId(long ExpenseRequisitionId) { try { #region Current Session Check var user = System.Web.HttpContext.Current.User.Identity.Name; var userData = MvcApplication.GetUserData(user); if (userData == null || userData.UserId < 1) { return(decimal.Zero); } #endregion var searchObj = new RetirementSearchObj { AdminUserId = userData.UserId, RetirementId = 0, StartDate = "", StopDate = "", VoucheNumber = "", Status = -1000 }; var retVal = RetirementServices.LoadRetirements(searchObj, userData.Username); if (retVal?.Status == null) { return(decimal.Zero); } if (retVal.Retirements == null || !retVal.Retirements.Any()) { return(decimal.Zero); } var retirement = retVal.Retirements.SingleOrDefault(x => x.ExpenseRequisitionId == ExpenseRequisitionId); if (retirement == null) { return(decimal.Zero); } return(retirement.AmountRetired); } catch (Exception ex) { return(decimal.Zero); } }
public ActionResult enviarCorreoRecuparaContrasena(string __a, string __b, string __c) { if (ModelState.IsValid) { var body = "<center><h1>Recuperación de Contraseña</h1></center> <p> Usuario : " + __a + ", su contraseña es : " + __c + "</p><p>Ingrese al sistema :</p><p></p><p></p><p>Atte.</p><p>Administrador Web</p><p>Lecturas</p>"; var message = new MailMessage(); message.To.Add(new MailAddress(__b)); message.From = new MailAddress("*****@*****.**"); message.Subject = "Recuperación de Correo - Sistema de Lecturas"; message.Body = body; message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { //UserName = "******", //Password = "******" UserName = "******", Password = "******" }; smtp.Credentials = credential; //smtp.Host = "smtp.live.com"; //smtp.Port = 25; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.Send(message); return(new ContentResult { Content = MvcApplication._Serialize(message), ContentType = "application/json" }); } } else { return(View()); } }
public JsonResult List(int year, int count) { IDatabaseAccessor dbAccess = new SqlDatabaseAccessor(MvcApplication.GetMockDraftConnectionStringName()); List <DProspect> dProspects = dbAccess.GetTopProspects(year, count); List <WProspect> prospects = new List <WProspect>(); foreach (var dProspect in dProspects) { prospects.Add(Mapper.Map <WProspect>(dProspect)); } return(new JsonResult { Data = prospects, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public void UserShouldNotBeAbleToForOthers(string username, string action, string contentType, string otherName) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var memberShipService = environment.Resolve <IMembershipService>(); var athorizationService = environment.Resolve <IAuthorizationService>(); var contentManager = environment.Resolve <IContentManager>(); var contentItem = contentManager.Create(contentType); var user = memberShipService.GetUser(username); var otherUser = memberShipService.GetUser(otherName); contentItem.As <ICommonPart>().Owner = otherUser; Assert.That(athorizationService.TryCheckAccess(GetPermissionForAction(action), user, contentItem), Is.False); } }); }
public JsonResult ProcessAddAlertTypeRequest(RegAlertTypeObj model) { try { var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false })); } if (model == null) { return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false })); } if (model.AlertProviderId < 2) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Invalid Alert Provider" })); } model.AdminUserId = userData.UserId; var response = AlertTypeService.AddAlertType(model, userData.Username); if (response?.Status == null) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Error Occurred! Please try again later" })); } if (!response.Status.IsSuccessful) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = string.IsNullOrEmpty(response.Status.Message.TechnicalMessage) ? "Process Failed! Unable to add nomination Source" : response.Status.Message.TechnicalMessage })); } Session["_AlertTypeList_"] = null; return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "" })); } catch (Exception ex) { UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Process Error Occurred! Please try again later" })); } }
public ActionResult _EditAlertNetwork(int id) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(View(new AlertNetworkObj())); } if (id < 1) { ViewBag.Error = "Invalid selection"; return(View(new AlertNetworkObj())); } if (!(Session["_AlertNetworkList_"] is List <AlertNetworkObj> AlertNetworkList) || AlertNetworkList.Count < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new AlertNetworkObj())); } var AlertNetwork = AlertNetworkList.Find(m => m.AlertNetworkId == id); if (AlertNetwork == null || AlertNetwork.AlertNetworkId < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new AlertNetworkObj())); } Session["_CurrentSelAlertNetwork_"] = AlertNetwork; AlertNetwork.StatusVal = AlertNetwork.Status == 1; return(View(AlertNetwork)); } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new AlertNetworkObj())); } }
private string SeeClickPhoto(T_UserClick Uclick, long id, string Items) { if (Uclick == null) { //如果没有添加一条用户点击信息 T_UserClick tucs = new T_UserClick(); tucs.UserInfoId = LoginUser.ID; tucs.ThisClick = 1; tucs.LoginClickTime = Convert.ToDateTime(MvcApplication.GetT_time().ToString("yyyy-MM-dd")); T_UserClickService.AddEntity(tucs); } else { DateTime logintime = Convert.ToDateTime(Uclick.LoginClickTime); if (logintime.ToString("yyyy-MM-dd") == MvcApplication.GetT_time().ToString("yyyy-MM-dd")) { Uclick.ThisClick = Uclick.ThisClick + 1; T_UserClickService.EditEntity(Uclick); } else if (logintime < MvcApplication.GetT_time()) { Uclick.ThisClick = 1; Uclick.LoginClickTime = Convert.ToDateTime(MvcApplication.GetT_time().ToString("yyyy-MM-dd")); T_UserClickService.EditEntity(Uclick); } } SeeQzCz scp = new SeeQzCz(); scp.Del = 0; scp.UserID = LoginUser.ID; if (Items == "QZ") { scp.QCItems = 0; scp.QiuZhuID = id; } else { scp.ChuZhuID = 1; scp.ChuZhuID = id; } SeeQzCzService.AddEntity(scp); return("OK"); }
public ActionResult _EditExpenseLookup(int ExpenseLookupId) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(View(new ExpenseLookupObj())); } if (ExpenseLookupId < 1) { ViewBag.Error = "Invalid selection"; return(View(new ExpenseLookupObj())); } if (!(Session["_ExpenseLookupList_"] is List <ExpenseLookupObj> ExpenseLookupList) || ExpenseLookupList.Count < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new ExpenseLookupObj())); } var ExpenseLookup = ExpenseLookupList.Find(m => m.ExpenseLookupId == ExpenseLookupId); if (ExpenseLookup == null || ExpenseLookup.ExpenseLookupId < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new ExpenseLookupObj())); } Session["_CurrentSelExpenseLookup_"] = ExpenseLookup; ExpenseLookup.StatusVal = ExpenseLookup.Status == 1; return(View(ExpenseLookup)); } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new ExpenseLookupObj())); } }
public void SearchControllerAndIndexActionRoutesToSearchUrl() { // Arrange RouteCollection routes = new RouteCollection(); MvcApplication.RegisterRoutes(routes); var httpContextMock = GetMockHttpContext(); RouteData routeData = new RouteData(); RequestContext context = new RequestContext(httpContextMock.Object, routeData); // Act string result = UrlHelper.GenerateUrl("Search", "Index", "Search", null, routes, context, true); // Assert Assert.AreEqual("/search", result, "Expected a different url"); }
public ActionResult EditWorkflowSetting(int WorkflowSettingId) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(View("EditWorkflowSetting", new WorkflowSettingObj())); } if (WorkflowSettingId < 1) { ViewBag.Error = "Invalid selection"; return(View("EditWorkflowSetting", new WorkflowSettingObj())); } if (!(Session["_WorkflowSettingList_"] is List <WorkflowSettingObj> WorkflowSettingList) || WorkflowSettingList.Count < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View("EditWorkflowSetting", new WorkflowSettingObj())); } var WorkflowSetting = WorkflowSettingList.Find(m => m.WorkflowSettingId == WorkflowSettingId); if (WorkflowSetting == null || WorkflowSetting.WorkflowSettingId < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View("EditWorkflowSetting", new WorkflowSettingObj())); } Session["_CurrentSelWorkflowSetting_"] = WorkflowSetting; WorkflowSetting.StatusVal = WorkflowSetting.Status == 1 ? true : false; return(View(WorkflowSetting)); } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View("EditWorkflowSetting", new WorkflowSettingObj())); } }
public ActionResult _EditBeneficiary(int BeneficiaryId) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(View(new BeneficiaryObj())); } if (BeneficiaryId < 1) { ViewBag.Error = "Invalid selection"; return(View(new BeneficiaryObj())); } if (!(Session["_BeneficiaryList_"] is List <BeneficiaryObj> BeneficiaryList) || BeneficiaryList.Count < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new BeneficiaryObj())); } var Beneficiary = BeneficiaryList.Find(m => m.BeneficiaryId == BeneficiaryId); if (Beneficiary == null || Beneficiary.BeneficiaryId < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new BeneficiaryObj())); } Session["_CurrentSelBeneficiary_"] = Beneficiary; Beneficiary.StatusVal = Beneficiary.Status == 1; return(View(Beneficiary)); } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new BeneficiaryObj())); } }
public void IndexViewWithLayoutTest() { // arrange var contents = SystemUnderTest.GetMvcApp1ContentProvider(); var action = new MvcApplication(contents) .Action(new HomeController(), "index"); using (var indexViewContent = contents.Open(@"Views\Home\Index.cshtml")) { // act var sw = new StringWriter(); action.RenderView(indexViewContent, sw); var output = sw.ToString(); // assert output.Should().Contain("<title>Home Page - My ASP.NET MVC Application</title>", "layout content should be included"); output.Should().Contain("<h3>We suggest the following:</h3>", "index content should be included"); } }
public ActionResult _EditSMSProvider(int id) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(View(new SMSProviderObj())); } if (id < 1) { ViewBag.Error = "Invalid selection"; return(View(new SMSProviderObj())); } if (!(Session["_SMSProviderList_"] is List <SMSProviderObj> SMSProviderList) || SMSProviderList.Count < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new SMSProviderObj())); } var SMSProvider = SMSProviderList.Find(m => m.SMSProviderId == id); if (SMSProvider == null || SMSProvider.SMSProviderId < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new SMSProviderObj())); } Session["_CurrentSelSMSProvider_"] = SMSProvider; SMSProvider.StatusVal = SMSProvider.Status == 1; return(View(SMSProvider)); } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new SMSProviderObj())); } }
public ActionResult _EditRequestTypeSetting(int RequestTypeSettingId) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(View(new RequestTypeSetting())); } if (RequestTypeSettingId < 1) { ViewBag.Error = "Invalid selection"; return(View(new RequestTypeSetting())); } if (!(Session["_RequestTypeSettingList_"] is List <RequestTypeSetting> RequestTypeSettingList) || RequestTypeSettingList.Count < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new RequestTypeSetting())); } var RequestTypeSetting = RequestTypeSettingList.Find(m => m.RequestTypeSettingId == RequestTypeSettingId); if (RequestTypeSetting == null || RequestTypeSetting.RequestTypeSettingId < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new RequestTypeSetting())); } Session["_CurrentSelRequestTypeSetting_"] = RequestTypeSetting; // RequestTypeSetting.StatusVal = RequestTypeSetting.Status == 1; return(View(RequestTypeSetting)); } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new RequestTypeSetting())); } }
public void DefineDefaultCulture(string cultureName) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var orchardServices = environment.Resolve <IOrchardServices>(); var cultureManager = environment.Resolve <ICultureManager>(); var currentCultures = cultureManager.ListCultures(); if (!currentCultures.Contains(cultureName)) { cultureManager.AddCulture(cultureName); } orchardServices.WorkContext.CurrentSite.SiteCulture = cultureName; } }); }
public ActionResult _EditClient(int clientId) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(View(new ClientObj())); } if (clientId < 1) { ViewBag.Error = "Invalid selection"; return(View(new ClientObj())); } if (!(Session["_ClientList_"] is List <ClientObj> clientList) || clientList.Count < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new ClientObj())); } var client = clientList.Find(m => m.ClientId == clientId); if (client == null || client.ClientId < 1) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(View(new ClientObj())); } Session["_CurrentSelClient_"] = client; client.StatusVal = client.Status == 1; return(View(client)); } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new ClientObj())); } }
public static void Register(MvcApplication application) { var builder = new ContainerBuilder(); builder.RegisterControllers(typeof(MvcApplication).Assembly); builder.RegisterInstance(new NhibernateInitializer().BuildSessionFactory()).As<ISessionFactory>().SingleInstance(); builder.Register(x => x.Resolve<ISessionFactory>().OpenSession()).As<ISession>().InstancePerLifetimeScope().OnActivating(a => Logger.Debug("ISession activating")).OnActivated(a => Logger.Debug("ISession activated")).OnPreparing(a => Logger.Debug("ISession Preparing")).OnRelease(x => { x.Dispose(); x = null; Logger.Debug("Autofac: ISession dispousing"); }); builder.RegisterType<NHibernateUnitOfWork>().As<IUnitOfWork, INHibernateUnitOfWork>(); //repositories builder.RegisterType<PostRepository>().As<IPostRepository>(); builder.RegisterType<InstagramRepository>().As<IInstagramRepository>(); builder.RegisterType<SettingsRepository>().As<ISettingsRepository>(); builder.RegisterType<FlickrRepository>().As<IFlickrRepository>(); builder.RegisterType<UserRepository>().As<IUserRepository>(); builder.RegisterType<InstagramService>().As<IInstagramService>(); builder.RegisterType<FlickrService>().As<IFlickrService>(); builder.RegisterType<ApplicationSettingsProvider>().As<IApplicationSettingsProvider>(); builder.RegisterType<WebsiteInfoProvider>().As<IWebsiteInfoProvider>(); builder.RegisterType<BlogMembershipProvider>(); builder.RegisterType<BlogRoleProvider>(); builder.RegisterType<BlogMembershipProvider>().As<MembershipProvider>(); //register filter builder.RegisterType<InstagramGlobalFilter>().As<IActionFilter>(); builder.RegisterType<Post>(); //Inject HTTP Abstractions builder.RegisterModule(new AutofacWebTypesModule()); // filters builder.RegisterFilterProvider(); var container = builder.Build(); DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); MvcApplication.AutofaqContainer = container; NhibernateInitializer.Container = container; }
public static HttpControllerAction Action(this ControllerContainer controllerContainer, string url) { var mvcApplication = new MvcApplication(controllerContainer, new EmptyContentProvider()); return new HttpControllerAction(mvcApplication) { UriPath = url }; }
public void Application_Start() { MvcApplication mvcApplication = new MvcApplication(); mvcApplication.Application_Start(); }