protected LocalPluginsModel PrepareLocalPluginsModel() { var plugins = _pluginFinder.GetPluginDescriptors(false) .OrderBy(p => p.Group, PluginFileParser.KnownGroupComparer) .ThenBy(p => p.DisplayOrder) .Select(x => PreparePluginModel(x)); var model = new LocalPluginsModel(); model.AvailableStores = Services.StoreService .GetAllStores() .Select(s => s.ToModel()) .ToList(); var groupedPlugins = from p in plugins group p by p.Group into g select g; foreach (var group in groupedPlugins) { foreach (var plugin in group) { model.Groups.Add(group.Key, plugin); } } return(model); }
private GridModel <PluginModel> PreparePluginListModel() { var pluginDescriptors = _pluginFinder.GetPluginDescriptors(false); var model = new GridModel <PluginModel> { Data = pluginDescriptors.Select(x => PreparePluginModel(x)) .OrderBy(x => x.Group) .ThenBy(x => x.DisplayOrder).ToList(), Total = pluginDescriptors.Count() }; return(model); }
/// <summary> /// Prepare plugins enabled warning model /// </summary> /// <param name="models">List of system warning models</param> protected virtual void PreparePluginsEnabledWarningModel(List <SystemWarningModel> models) { var pluginDescriptors = _pluginFinder.GetPluginDescriptors(); var notEnabled = new List <string>(); foreach (var plugin in pluginDescriptors.Select(pd => pd.Instance())) { var isEnabled = true; switch (plugin) { case IPaymentMethod paymentMethod: isEnabled = _paymentService.IsPaymentMethodActive(paymentMethod); break; case IShippingRateComputationMethod shippingRateComputationMethod: isEnabled = _shippingService.IsShippingRateComputationMethodActive(shippingRateComputationMethod); break; case IPickupPointProvider pickupPointProvider: isEnabled = _shippingService.IsPickupPointProviderActive(pickupPointProvider); break; case ITaxProvider _: isEnabled = plugin.PluginDescriptor.SystemName .Equals(_taxSettings.ActiveTaxProviderSystemName, StringComparison.InvariantCultureIgnoreCase); break; case IExternalAuthenticationMethod externalAuthenticationMethod: isEnabled = _externalAuthenticationService.IsExternalAuthenticationMethodActive(externalAuthenticationMethod); break; case IWidgetPlugin widgetPlugin: isEnabled = _widgetService.IsWidgetActive(widgetPlugin); break; case IExchangeRateProvider exchangeRateProvider: isEnabled = exchangeRateProvider.PluginDescriptor.SystemName == _currencySettings.ActiveExchangeRateProviderSystemName; break; } if (isEnabled) { continue; } notEnabled.Add(plugin.PluginDescriptor.FriendlyName); } if (notEnabled.Any()) { models.Add(new SystemWarningModel { Level = SystemWarningLevel.Warning, Text = $"{_localizationService.GetResource("Admin.System.Warnings.PluginNotEnabled")}: {string.Join(", ", notEnabled)}" }); } }
public ActionResult Create(LanguageModel model, bool continueEditing) { if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageLanguages)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var language = model.ToEntity(); _languageService.InsertLanguage(language); SaveStoreMappings(language, model); var plugins = _pluginFinder.GetPluginDescriptors(true); var filterLanguages = new List <Language>() { language }; foreach (var plugin in plugins) { _services.Localization.ImportPluginResourcesFromXml(plugin, null, false, filterLanguages); } NotifySuccess(T("Admin.Configuration.Languages.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = language.Id }) : RedirectToAction("List")); } PrepareLanguageModel(model, null, true); // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Create(LanguageModel model, bool continueEditing) { if (ModelState.IsValid) { var language = model.ToEntity(); _languageService.InsertLanguage(language); SaveStoreMappings(language, model.SelectedStoreIds); var plugins = _pluginFinder.GetPluginDescriptors(true); var filterLanguages = new List <Language>() { language }; foreach (var plugin in plugins) { _services.Localization.ImportPluginResourcesFromXml(plugin, null, false, filterLanguages); } NotifySuccess(T("Admin.Configuration.Languages.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = language.Id }) : RedirectToAction("List")); } PrepareLanguageModel(model, null, true); return(View(model)); }
//初始化list页面 public override List <PluginView> GetListEx(Expression <Func <PluginModel, bool> > predicate, PageCondition ConPage) { string strModeId = Request["SearchLoadModeId"]; string strGroup = Request["SearchGroup"]; LoadPluginsMode loadMode = LoadPluginsMode.All; if (!string.IsNullOrEmpty(strModeId)) { loadMode = (LoadPluginsMode)int.Parse(strModeId); } // ConPage.SortConditions.Add(new SortCondition("CreatedDate", System.ComponentModel.ListSortDirection.Descending)); // var q = _objService.GetList<PluginView>(predicate, ConPage); var pluginDescriptors = _pluginFinder.GetPluginDescriptors(loadMode, 0, strGroup).ToList(); //var pluginDescriptors = PluginManager.AllPlugins; ConPage.RowCount = pluginDescriptors.Count(); return(pluginDescriptors.Select(x => PreparePluginModel(x, false)).Select(x => (PluginView) new PluginView().ConvertAPIModel(x)).ToList()); }
public ActionResult Plugins() { var plugins = _pluginFinder.GetPluginDescriptors(LoadPluginsMode.All).OrderBy(x => x.DisplayOrder).AsQueryable(); var grid = new PluginsGrid(plugins); return(View(grid)); }
public virtual async Task <IActionResult> Get([FromBody] KendoGridMvcRequest request) { var query = pluginFinder.GetPluginDescriptors(LoadPluginsMode.All).Select(x => (EdmPluginDescriptor)x).AsQueryable(); var grid = new KendoGrid <EdmPluginDescriptor>(request, query); return(Json(grid, new JsonSerializerSettings { ContractResolver = new DefaultContractResolver() })); }
public ActionResult ListSelect(DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins)) { return(AccessDeniedView()); } var pluginDescriptors = _pluginFinder.GetPluginDescriptors(false).ToList(); var gridModel = new DataSourceResult { Data = pluginDescriptors.Select(x => PreparePluginModel(x, false, false)) .OrderBy(x => x.Group) .ToList(), Total = pluginDescriptors.Count() }; return(Json(gridModel)); }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins)) { return(AccessDeniedView()); } //TODO allow store owner to edit display order of plugins var pluginDescriptors = _pluginFinder.GetPluginDescriptors(false); var model = new GridModel <PluginModel> { Data = pluginDescriptors.Select(x => PreparePluginModel(x)) .OrderBy(x => x.Group) .ThenBy(x => x.DisplayOrder).ToList(), Total = pluginDescriptors.Count() }; return(View(model)); }
public async Task <ActionResult> PaymentSetting() { // Get payment info var model = new PaymentSettingModel() { Setting = CacheHelper.Settings, PaymentPlugins = _pluginFinder.GetPluginDescriptors(LoadPluginsMode.InstalledOnly, "Payment").ToList() }; return(View(model)); }
public JsonResult List(PluginListModel model) { var loadMode = (LoadPluginsMode)model.SearchLoadModeId; var pluginDescriptors = _pluginFinder.GetPluginDescriptors(loadMode, group: model.SearchGroup).ToList(); var data = pluginDescriptors.Select(x => { return(PreparePluginModel(x)); }); return(Json(new { data = data })); }
private void InstallPlugins() { // Install plugin marked as installed var plugins = _pluginFinder.GetPluginDescriptors(LoadPluginsMode.InstalledOnly); foreach (var plugin in plugins) { plugin.Instance().Install(); plugin.Instance().Enable(true); } }
public IActionResult ListSelect(DataSourceRequest command, PluginListModel model) { var loadMode = (LoadPluginsMode)model.SearchLoadModeId; var pluginDescriptors = _pluginFinder.GetPluginDescriptors(loadMode, "", model.SearchGroup).ToList(); var gridModel = new DataSourceResult { Data = pluginDescriptors.Select(x => PreparePluginModel(x, false, false)) .OrderBy(x => x.Group) .ToList(), Total = pluginDescriptors.Count() }; return(Json(gridModel)); }
public void Start(HttpContextBase httpContext) { //if (!PluginManager.PluginChangeDetected) // return; var descriptors = _pluginFinder.GetPluginDescriptors(true); foreach (var d in descriptors) { var hasher = _locService.CreatePluginResourcesHasher(d); if (hasher.HasChanged) { _locService.ImportPluginResourcesFromXml(d, null, false); } } }
public async Task <IActionResult> ListSelect(DataSourceRequest command, PluginListModel model) { var loadMode = (LoadPluginsMode)model.SearchLoadModeId; var pluginDescriptors = _pluginFinder.GetPluginDescriptors(loadMode, "", model.SearchGroup).ToList(); var items = new List <PluginModel>(); foreach (var item in pluginDescriptors.OrderBy(x => x.Group)) { items.Add(await PreparePluginModel(item, false, false)); } var gridModel = new DataSourceResult { Data = items, Total = pluginDescriptors.Count() }; return(Json(gridModel)); }
public ActionResult ListSelect(DataSourceRequest command, PluginListModel model) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins)) //return AccessDeniedView(); var loadMode = (LoadPluginsMode)model.SearchLoadModeId; var pluginDescriptors = _pluginFinder.GetPluginDescriptors(loadMode, "", model.SearchGroup).ToList(); var gridModel = new DataSourceResult { Data = pluginDescriptors.Select(x => PreparePluginModel(x, false, false)) .OrderBy(x => x.Group) .ToList(), Total = pluginDescriptors.Count() }; return(Json(gridModel)); }
public Task <IPagedList <PluginDescriptor> > PluginsPaged(int pageSize, int pageIndex, string queryString, bool?isInstalled) { return(Task.Run <IPagedList <PluginDescriptor> >(() => { var list = _pluginFinder.GetPluginDescriptors(); if (isInstalled.HasValue) { list = list.Where(a => a.Installed == isInstalled); } if (!string.IsNullOrEmpty(queryString)) { list = list.Where(a => a.FriendlyName.Contains(queryString)); } return list.ToPagedList(pageSize, pageIndex); })); }
public ActionResult Index() { var model = CacheHelper.Statistics; model.TransactionCount = 0; // Get transaction count var descriptors = _pluginFinder.GetPluginDescriptors(LoadPluginsMode.InstalledOnly, "Payment"); foreach (var descriptor in descriptors) { var controllerType = descriptor.Instance <IHookPlugin>().GetControllerType(); var controller = ContainerManager.GetConfiguredContainer().Resolve(controllerType) as IPaymentController; model.TransactionCount += controller.GetTransactionCount(); } return(View("Dashboard", model)); }
// GET: odata/kore/cms/Plugins //[EnableQuery(AllowedQueryOptions = AllowedQueryOptions.All)] public virtual IEnumerable <EdmPluginDescriptor> Get(ODataQueryOptions <EdmPluginDescriptor> options) { if (!CheckPermission(StandardPermissions.FullAccess)) { return(Enumerable.Empty <EdmPluginDescriptor>().AsQueryable()); } var settings = new ODataValidationSettings() { AllowedQueryOptions = AllowedQueryOptions.All }; options.Validate(settings); var query = pluginFinder.GetPluginDescriptors(false).Select(x => (EdmPluginDescriptor)x).AsQueryable(); var results = options.ApplyTo(query); return((results as IQueryable <EdmPluginDescriptor>).ToHashSet()); }
/// <summary> /// Prepare plugins enabled warning model /// </summary> /// <param name="models">List of system warning models</param> protected virtual void PreparePluginsEnabledWarningModel(List <SystemWarningModel> models) { var pluginDescriptors = _pluginFinder.GetPluginDescriptors(); var notEnabled = new List <string>(); foreach (var plugin in pluginDescriptors.Select(pd => pd.Instance())) { var isEnabled = true; switch (plugin) { case IExternalAuthenticationMethod externalAuthenticationMethod: isEnabled = _externalAuthenticationService.IsExternalAuthenticationMethodActive(externalAuthenticationMethod); break; case IWidgetPlugin widgetPlugin: isEnabled = _widgetService.IsWidgetActive(widgetPlugin); break; case IExchangeRateProvider exchangeRateProvider: isEnabled = exchangeRateProvider.PluginDescriptor.SystemName == _currencySettings.ActiveExchangeRateProviderSystemName; break; } if (isEnabled) { continue; } notEnabled.Add(plugin.PluginDescriptor.FriendlyName); } if (notEnabled.Any()) { models.Add(new SystemWarningModel { Level = SystemWarningLevel.Warning, Text = $"{_localizationService.GetResource("Admin.System.Warnings.PluginNotEnabled")}: {string.Join(", ", notEnabled)}" }); } }
/// <summary> /// Prepare paged plugin list model /// </summary> /// <param name="searchModel">Plugin search model</param> /// <returns>Plugin list model</returns> public virtual PluginListModel PreparePluginListModel(PluginSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get parameters to filter plugins var group = string.IsNullOrEmpty(searchModel.SearchGroup) || searchModel.SearchGroup.Equals("0") ? null : searchModel.SearchGroup; var loadMode = (LoadPluginsMode)searchModel.SearchLoadModeId; //get plugins var plugins = _pluginFinder.GetPluginDescriptors(group: group, loadMode: loadMode) .OrderBy(plugin => plugin.Group).ToList(); //prepare list model var model = new PluginListModel { Data = plugins.PaginationByRequestModel(searchModel).Select(pluginDescriptor => { //fill in model values from the entity var pluginModel = pluginDescriptor.ToPluginModel <PluginModel>(); //fill in additional values (not existing in the entity) pluginModel.LogoUrl = PluginManager.GetLogoUrl(pluginDescriptor); if (pluginDescriptor.Installed) { PrepareInstalledPluginModel(pluginModel, pluginDescriptor.Instance()); } return(pluginModel); }), Total = plugins.Count }; return(model); }
public virtual ActionResult GridDataSource(DataManager dm) { var dataSource = _pluginFinder.GetPluginDescriptors(LoadPluginsMode.All).ToList().Select(p => new { Info = "<small><b>" + _localizationService.GetResource("Author") + ": </b>" + p.Author + "<br/>" + "<b>" + _localizationService.GetResource("SystemName") + ": </b>" + p.SystemName + "<br/>" + "<b>" + _localizationService.GetResource("Version") + ": </b>" + p.Version + "<br/>" + "<b>" + _localizationService.GetResource("Installed") + ": </b>" + (p.Installed ? "<i class=\"fa fa-check\" aria-hidden=\"true\"></i>" : "<i class=\"fa fa-times\" aria-hidden=\"true\"></i>") + "</small>", p.Installed, Name = "<b>" + p.FriendlyName + "</b><br/><small><b>" + _localizationService.GetResource("Description") + ": </b><br/>" + p.Description + "</small>", LogoUrl = p.GetLogoUrl(), p.SystemName, p.Group, p.DisplayOrder }); var result = dataSource.AsQueryable().ApplyDataManager(dm, out var count).ToList(); return(Json(dm.RequiresCounts ? new { result = result, count = count } : (object)result, JsonRequestBehavior.AllowGet)); }
public PluginReferenceRepository(IProjectSystem project, IPackageRepository sourceRepository, IPluginFinder pluginFinder) : base(project, sourceRepository) { _pluginFinder = pluginFinder; _descriptors = _pluginFinder.GetPluginDescriptors().ToList(); }
public async Task <ActionResult> Order(Model.Models.Order order) { var listing = await _listingService.FindAsync(order.ListingID); var ordersListing = await _orderService.Query(x => x.ListingID == order.ListingID).SelectAsync(); if ((order.ToDate.Value - order.FromDate.Value).Days < 2) { TempData[TempDataKeys.UserMessageAlertState] = "bg-danger"; TempData[TempDataKeys.UserMessage] = "[[[The minium quantity for order is two nights]]]"; return(RedirectToAction("Listing", "Listing", new { id = order.ListingID })); } if (order.ToDate < order.FromDate) { TempData[TempDataKeys.UserMessageAlertState] = "bg-danger"; TempData[TempDataKeys.UserMessage] = "[[[The date of check out can't be less than the check in date]]]"; return(RedirectToAction("Listing", "Listing", new { id = order.ListingID })); } if ((order.Children + order.Adults) > listing.Max_Capacity) { TempData[TempDataKeys.UserMessageAlertState] = "bg-danger"; TempData[TempDataKeys.UserMessage] = string.Format("La maxima capacidad de pasajeros es de {0}", listing.Max_Capacity); return(RedirectToAction("Listing", "Listing", new { id = order.ListingID })); } if (listing == null) { return(new HttpNotFoundResult()); } // Redirect if not authenticated if (!User.Identity.IsAuthenticated) { if (Session["fechas"] != null) { SearchListingModel fecha = (SearchListingModel)Session["fechas"]; fecha.FromDate = order.FromDate; fecha.ToDate = order.ToDate; fecha.Niños = order.Children; fecha.Passengers = order.Adults; Session["fechas"] = fecha; } return(RedirectToAction("Login", "Account", new { ReturnUrl = Url.Action("Listing", "Listing", new { id = order.ListingID }), FromDate = order.FromDate, ToDate = order.ToDate, Adults = order.Adults, Children = order.Children })); } var userCurrent = User.Identity.User(); //validar que los dias no esten reservados List <DateTime> FechasCocinadas = new List <DateTime>(); for (DateTime date = order.FromDate.Value; date < order.ToDate.Value; date = date.Date.AddDays(1)) { FechasCocinadas.Add(date); } foreach (Model.Models.Order ordenesArrendadas in ordersListing.Where(x => x.Status != (int)Enum_OrderStatus.Cancelled)) { for (DateTime date = ordenesArrendadas.FromDate.Value; date < ordenesArrendadas.ToDate.Value; date = date.Date.AddDays(1)) { if (FechasCocinadas.Contains(date)) { TempData[TempDataKeys.UserMessageAlertState] = "bg-danger"; TempData[TempDataKeys.UserMessage] = "[[[You can not book with these selected dates!]]]"; return(RedirectToAction("Listing", "Listing", new { id = listing.ID })); } } } // Check if payment method is setup on user or the platform var descriptors = _pluginFinder.GetPluginDescriptors <IHookPlugin>(LoadPluginsMode.InstalledOnly, "Payment").Where(x => x.Enabled); if (descriptors.Count() == 0) { TempData[TempDataKeys.UserMessageAlertState] = "bg-danger"; TempData[TempDataKeys.UserMessage] = "[[[The provider has not setup the payment option yet, please contact the provider.]]]"; return(RedirectToAction("Listing", "Listing", new { id = order.ListingID })); } if (!User.IsInRole("Administrator")) { if (listing.UserID != userCurrent.Id) { //foreach (var descriptor in descriptors) //{ // var controllerType = descriptor.Instance<IHookPlugin>().GetControllerType(); // var controller = ContainerManager.GetConfiguredContainer().Resolve(controllerType) as IPaymentController; // if (!controller.HasPaymentMethod(listing.UserID)) // { // TempData[TempDataKeys.UserMessageAlertState] = "bg-danger"; // TempData[TempDataKeys.UserMessage] = string.Format("[[[The provider has not setup the payment option for {0} yet, please contact the provider.]]]", descriptor.FriendlyName); // return RedirectToAction("Listing", "Listing", new { id = order.ListingID }); // } //} if (order.ID == 0) { order.ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added; order.Created = DateTime.Now; order.Modified = DateTime.Now; order.Status = (int)Enum_OrderStatus.Created; order.UserProvider = listing.UserID; order.UserReceiver = userCurrent.Id; order.ListingTypeID = order.ListingTypeID; order.Currency = listing.Currency; order.OrderType = 3; order.Price = 0; order.Quantity = 0; var listingPrice = await _listingPriceService.Query(x => x.ListingID == order.ListingID).SelectAsync(); var precioEnero = listingPrice.FirstOrDefault(x => x.FromDate.Month.Equals(01)); var precioFebrero = listingPrice.FirstOrDefault(x => x.FromDate.Month.Equals(02)); for (DateTime date = order.FromDate.Value; date <= order.ToDate.Value.AddDays(-1); date = date.Date.AddDays(1)) { if (date >= precioEnero.FromDate && date <= precioEnero.ToDate) { order.Price = order.Price + precioEnero.Price; order.Quantity = order.Quantity + 1; } else if (date >= precioFebrero.FromDate && date <= precioFebrero.ToDate) { order.Price = order.Price + precioFebrero.Price; order.Quantity = order.Quantity + 1; } else { order.Price = order.Price + listing.Price; order.Quantity = order.Quantity + 1; } } var servicio = order.Price * 0.04; order.Total = order.Price + listing.CleanlinessPrice + servicio; order.Description = HttpContext.ParseAndTranslate( string.Format("{0} #{1} ([[[From]]] {2} [[[To]]] {3})", listing.Title, listing.ID, order.FromDate.Value.ToShortDateString(), order.ToDate.Value.ToShortDateString())); _orderService.Insert(order); var provider = await _aspNetUserService.FindAsync(order.UserProvider); //await EnviarCorreo(confirmacion, provider.Email); } await _unitOfWorkAsync.SaveChangesAsync(); ClearCache(); return(RedirectToAction("ConfirmOrder", "Payment", new { id = order.ID })); } else { order.OrderType = 2; if (order.ID == 0) { order.ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added; order.Created = DateTime.Now; order.Modified = DateTime.Now; order.Status = (int)Enum_OrderStatus.Pending; order.UserProvider = listing.UserID; order.UserReceiver = userCurrent.Id; order.ListingTypeID = order.ListingTypeID; order.Currency = listing.Currency; if (order.ToDate.HasValue && order.FromDate.HasValue) { order.Description = HttpContext.ParseAndTranslate( string.Format("{0} #{1} ([[[From]]] {2} [[[To]]] {3})", listing.Title, listing.ID, order.FromDate.Value.ToShortDateString(), order.ToDate.Value.ToShortDateString())); order.Quantity = order.ToDate.Value.Subtract(order.FromDate.Value.Date).Days; order.Price = 0; } else if (order.Quantity.HasValue) { order.Description = string.Format("{0} #{1}", listing.Title, listing.ID); order.Quantity = order.Quantity.Value - 1; order.Price = 0; } else { // Default order.Description = string.Format("{0} #{1}", listing.Title, listing.ID); order.Quantity = 1; order.Price = 0; } _orderService.Insert(order); } await _unitOfWorkAsync.SaveChangesAsync(); ClearCache(); TempData[TempDataKeys.UserMessage] = string.Format("[[[Has bloqueado correctamenter tu propiedad entre las fechas {0} y {1}]]]", order.FromDate.Value.ToString("dd-MM-yyyy"), order.ToDate.Value.ToString("dd-MM-yyyy")); return(RedirectToAction("Listing", "Listing", new { id = listing.ID })); } } else { order.OrderType = 1; if (order.ID == 0) { order.ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added; order.Created = DateTime.Now; order.Modified = DateTime.Now; order.Status = (int)Enum_OrderStatus.Pending; order.UserProvider = listing.UserID; order.UserReceiver = userCurrent.Id; order.ListingTypeID = order.ListingTypeID; order.Currency = listing.Currency; if (order.ToDate.HasValue && order.FromDate.HasValue) { order.Description = HttpContext.ParseAndTranslate( string.Format("{0} #{1} ([[[From]]] {2} [[[To]]] {3})", listing.Title, listing.ID, order.FromDate.Value.ToShortDateString(), order.ToDate.Value.ToShortDateString())); order.Quantity = order.ToDate.Value.Subtract(order.FromDate.Value.Date).Days; order.Price = 0; } else if (order.Quantity.HasValue) { order.Description = string.Format("{0} #{1}", listing.Title, listing.ID); order.Quantity = order.Quantity.Value - 1; order.Price = 0; } else { // Default order.Description = string.Format("{0} #{1}", listing.Title, listing.ID); order.Quantity = 1; order.Price = 0; } _orderService.Insert(order); } await _unitOfWorkAsync.SaveChangesAsync(); ClearCache(); TempData[TempDataKeys.UserMessage] = "[[[The maintenance was scheduled successfully!]]]"; return(RedirectToAction("Listing", "Listing", new { id = listing.ID })); } }
public async Task <ActionResult> Order(Order order) { var listing = await _listingService.FindAsync(order.ListingID); if (listing == null) { return(new HttpNotFoundResult()); } var userCurrent = User.Identity.User(); // Check if payment method is setup on user or the platform var descriptors = _pluginFinder.GetPluginDescriptors <IHookPlugin>(LoadPluginsMode.InstalledOnly, "Payment").Where(x => x.Enabled); if (descriptors.Count() == 0) { TempData[TempDataKeys.UserMessageAlertState] = "bg-danger"; TempData[TempDataKeys.UserMessage] = "[[[The provider has not setup the payment option yet, please contact the provider.]]]"; return(RedirectToAction("Listing", "Listing", new { id = order.ListingID })); } foreach (var descriptor in descriptors) { var controllerType = descriptor.Instance <IHookPlugin>().GetControllerType(); var controller = ContainerManager.GetConfiguredContainer().Resolve(controllerType) as IPaymentController; if (!controller.HasPaymentMethod(listing.UserID)) { TempData[TempDataKeys.UserMessageAlertState] = "bg-danger"; TempData[TempDataKeys.UserMessage] = string.Format("[[[The provider has not setup the payment option for {0} yet, please contact the provider.]]]", descriptor.FriendlyName); return(RedirectToAction("Listing", "Listing", new { id = order.ListingID })); } } if (order.ID == 0) { order.ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added; order.Created = DateTime.Now; order.Modified = DateTime.Now; order.Status = (int)Enum_OrderStatus.Created; order.UserProvider = listing.UserID; order.UserReceiver = userCurrent.Id; order.ListingTypeID = order.ListingTypeID; order.Currency = listing.Currency; if (order.UserProvider == order.UserReceiver) { TempData[TempDataKeys.UserMessageAlertState] = "bg-danger"; TempData[TempDataKeys.UserMessage] = "[[[You cannot book the item from yourself!]]]"; return(RedirectToAction("Listing", "Listing", new { id = order.ListingID })); } if (order.ToDate.HasValue && order.FromDate.HasValue) { order.Description = HttpContext.ParseAndTranslate( string.Format("{0} #{1} ([[[From]]] {2} [[[To]]] {3})", listing.Title, listing.ID, order.FromDate.Value.ToShortDateString(), order.ToDate.Value.ToShortDateString())); order.Quantity = order.ToDate.Value.Date.AddDays(1).Subtract(order.FromDate.Value.Date).Days; order.Price = order.Quantity * listing.Price; } else if (order.Quantity.HasValue) { order.Description = string.Format("{0} #{1}", listing.Title, listing.ID); order.Quantity = order.Quantity.Value; order.Price = listing.Price; } else { // Default order.Description = string.Format("{0} #{1}", listing.Title, listing.ID); order.Quantity = 1; order.Price = listing.Price; } _orderService.Insert(order); } await _unitOfWorkAsync.SaveChangesAsync(); ClearCache(); return(RedirectToAction("Payment", new { id = order.ID })); }
// // GET: /Configuration/Plugins/ public ActionResult List() { var pluginDescriptors = pluginFinder.GetPluginDescriptors(PluginsType.All, null); return(View(pluginDescriptors.ToList())); }