public SetCommand(MiscService misc, DbService db, InteractiveService inter, RandomService rand) { _misc = misc; _db = db; _inter = inter; _rand = rand; }
public DrawTextCommand(DiscordShardedClient client, ImageService img, MiscService misc, NetService net) { _client = client; _img = img; _misc = misc; _net = net; }
public CommandsCommand(CommandService commands, MiscService misc, RandomService rand, InteractiveService inter) { _commands = commands; _misc = misc; _rand = rand; _inter = inter; }
public HelpCommand(CommandService commands, MiscService misc, IServiceProvider services, InteractiveService inter) { _commands = commands; _misc = misc; _services = services; _inter = inter; }
public ActionResult Delete(int id) { var post = MiscService.GetById(id); if (post is null) { return(ResultData(null, false, "杂项页已经被删除!")); } var srcs = post.Content.MatchImgSrcs().Where(s => s.StartsWith("/")); foreach (var path in srcs) { try { System.IO.File.Delete(Path.Combine(HostEnvironment.WebRootPath + path)); } catch (IOException) { } } bool b = MiscService.DeleteByIdSaved(id); return(ResultData(null, b, b ? "删除成功" : "删除失败")); }
public ImageInfoCommand(DiscordShardedClient client, ImageService img, MiscService misc, RandomService rand) { _client = client; _img = img; _misc = misc; _rand = rand; }
public StockInvoiceController(IStockInvoiceService svc, ISupplierService supSvc, MiscService miscService) { _stockInvSvc = svc; _supSvc = supSvc; _miscService = miscService; InitialiseSuppliersViewBag(supSvc); InitialiseExchangeRateViewBag(supSvc); }
public RedditDownloadCommand(DiscordShardedClient client, MiscService misc, ImageService img, RandomService rand, NetService net) { _client = client; _misc = misc; _img = img; _rand = rand; _net = net; }
public async Task <ActionResult> Write(Misc model) { model.Content = await ImagebedClient.ReplaceImgSrc(model.Content.Trim().ClearImgAttributes()); var e = MiscService.AddEntitySaved(model); return(e != null?ResultData(null, message : "发布成功") : ResultData(null, false, "发布失败")); }
static ServiceHelper() { Workshop = new WorkshopService(); Student = new StudentService(); Booking = new BookingService(); Misc = new MiscService(); Task.Factory.StartNew(HelpsService.Purge); }
public async Task <ActionResult> Write([FromBodyOrDefault] Misc model, CancellationToken cancellationToken) { model.Content = await ImagebedClient.ReplaceImgSrc(await model.Content.Trim().ClearImgAttributes(), cancellationToken); var e = MiscService.AddEntitySaved(model); return(e != null?ResultData(null, message : "发布成功") : ResultData(null, false, "发布失败")); }
public async Task <ActionResult> Index(int id) { var misc = await MiscService.GetFromCacheAsync(m => m.Id == id) ?? throw new NotFoundException("页面未找到"); misc.ModifyDate = misc.ModifyDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); misc.PostDate = misc.PostDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); return(View(misc)); }
public void GetNumericEntity_ReturnsNumberFromDictionary_Test() { Dictionary <string, object> testParameters = new Dictionary <string, object>(); testParameters.Add("name", "John"); testParameters.Add("number", 3); Assert.Equal(3, MiscService.GetNumericEntity(testParameters)); }
public MusicModule(AudioService audio, DiscordShardedClient client, MiscService misc, MusicService ms, DbService db, IServiceProvider services) { _audio = audio; _client = client; _misc = misc; _ms = ms; _db = db; _services = services; }
public void GetFoodEntities_ReturnsWhenNoRecipeInDictionary_Test() { Dictionary <string, object> testParameters = new Dictionary <string, object>(); testParameters.Add("name", "John"); testParameters.Add("age", 23); Assert.Equal(BotConstants.OtherConstants.DefaultRecipeDish, MiscService.GetFoodEntities(testParameters, BotConstants.FoodEntitiesEnum.Recipe)); }
public void GetFoodEntities_ReturnsRecipeItemFromDictionary_Test() { Dictionary <string, object> testParameters = new Dictionary <string, object>(); testParameters.Add("recipe", "Green salad with olives"); testParameters.Add("number", 5); Assert.Equal("Green salad with olives", MiscService.GetFoodEntities(testParameters, BotConstants.FoodEntitiesEnum.Recipe)); }
public void GetFoodEntities_ReturnsFoodItemFromDictionary_Test() { Dictionary <string, object> testParameters = new Dictionary <string, object>(); testParameters.Add("foodItem", "Basil"); testParameters.Add("number", 5); Assert.Equal("Basil", MiscService.GetFoodEntities(testParameters, BotConstants.FoodEntitiesEnum.FoodItem)); }
public void GetNumericEntity_ReturnsWhenNoNumberInDictionary_Test() { Dictionary <string, object> testParameters = new Dictionary <string, object>(); testParameters.Add("name", "John"); testParameters.Add("age", 23); Assert.Equal(BotConstants.OtherConstants.DefaultTopN, MiscService.GetNumericEntity(testParameters)); }
public void GetNumericEntity_HandlesEmptyStringInNumberValueFromDictionary_Test() { Dictionary <string, object> testParameters = new Dictionary <string, object>(); testParameters.Add("name", "John"); testParameters.Add("number", ""); Assert.Equal(5, MiscService.GetNumericEntity(testParameters)); }
public async Task YesNo_ShouldDelegateProperly() { var messagesMock = new Mock <IDiscordMessages>(); var service = new MiscService(messagesMock.Object); await service.SendRandomYesNoAnswerAsync(new MiunieChannel()).ConfigureAwait(false); messagesMock.Verify(m => m.SendMessageAsync(It.IsAny <MiunieChannel>(), It.Is <PhraseKey>(pk => pk == PhraseKey.YES_NO_MAYBE))); }
public void GetFoodEntities_ReturnsWhenNoFoodItemInDictionary_Test() { Dictionary <string, object> testParameters = new Dictionary <string, object>(); testParameters.Add("name", "John"); testParameters.Add("age", 23); Assert.Equal(BotConstants.OtherConstants.DefaultIngredientsSerialized, MiscService.GetFoodEntities(testParameters, BotConstants.FoodEntitiesEnum.FoodItem)); }
public ActionResult Index(int id) { Misc misc = MiscService.GetById(id); if (misc is null) { return(RedirectToAction("Index", "Error")); } return(View(misc)); }
public NewAccountController(CustomerService customerService, CustomerAccountService accountService, ItemChargeService itemChargeService, StockService stockService, ContractService contractService, MiscService miscService, AccountTransactionService accountTransactionService) { _customerService = customerService; _accountService = accountService; _itemChargeService = itemChargeService; _stockService = stockService; _contractService = contractService; _miscService = miscService; _accountTransactionService = accountTransactionService; }
public ActionResult Get(int id) { var misc = MiscService.GetById(id); if (misc != null) { misc.ModifyDate = misc.ModifyDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); misc.PostDate = misc.PostDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); } return(ResultData(misc.MapTo <MiscDto>())); }
public ActionResult Write(Misc model) { model.Content = CommonHelper.ReplaceImgSrc(Regex.Replace(model.Content?.Trim(), @"<img\s+[^>]*\s*src\s*=\s*['""]?(\S+\.\w{3,4})['""]?[^/>]*/>", "<img src=\"$1\"/>")).Replace("/thumb150/", "/large/"); var e = MiscService.AddEntitySaved(model); if (e != null) { return(ResultData(null, message: "发布成功")); } return(ResultData(null, false, "发布失败")); }
public ActionResult Edit(Misc misc) { var entity = MiscService.GetById(misc.Id); entity.ModifyDate = DateTime.Now; entity.Title = misc.Title; entity.Content = CommonHelper.ReplaceImgSrc(Regex.Replace(misc.Content, @"<img\s+[^>]*\s*src\s*=\s*['""]?(\S+\.\w{3,4})['""]?[^/>]*/>", "<img src=\"$1\"/>")).Replace("/thumb150/", "/large/"); bool b = MiscService.UpdateEntitySaved(entity); return(ResultData(null, b, b ? "修改成功" : "修改失败")); }
public async Task <ActionResult> Edit(Misc misc) { var entity = MiscService.GetById(misc.Id); entity.ModifyDate = DateTime.Now; entity.Title = misc.Title; entity.Content = await ImagebedClient.ReplaceImgSrc(misc.Content.ClearImgAttributes()); bool b = MiscService.SaveChanges() > 0; return(ResultData(null, b, b ? "修改成功" : "修改失败")); }
public async Task <ActionResult> Edit(Misc misc, CancellationToken cancellationToken) { var entity = await MiscService.GetByIdAsync(misc.Id) ?? throw new NotFoundException("杂项页未找到"); entity.ModifyDate = DateTime.Now; entity.Title = misc.Title; entity.Content = await ImagebedClient.ReplaceImgSrc(await misc.Content.ClearImgAttributes(), cancellationToken); bool b = await MiscService.SaveChangesAsync() > 0; return(ResultData(null, b, b ? "修改成功" : "修改失败")); }
public async Task <ActionResult> Get(int id) { var misc = await MiscService.GetByIdAsync(id); if (misc != null) { misc.ModifyDate = misc.ModifyDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); misc.PostDate = misc.PostDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); } return(ResultData(misc.Mapper <MiscDto>())); }
public ActionResult GetPageData(int page = 1, int size = 10) { var list = MiscService.GetPages(page, size, n => true, n => n.ModifyDate, false); foreach (var item in list.Data) { item.ModifyDate = item.ModifyDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); item.PostDate = item.PostDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); } return(Ok(list)); }