Example #1
0
 public SetCommand(MiscService misc, DbService db, InteractiveService inter, RandomService rand)
 {
     _misc  = misc;
     _db    = db;
     _inter = inter;
     _rand  = rand;
 }
Example #2
0
 public DrawTextCommand(DiscordShardedClient client, ImageService img, MiscService misc, NetService net)
 {
     _client = client;
     _img    = img;
     _misc   = misc;
     _net    = net;
 }
Example #3
0
 public CommandsCommand(CommandService commands, MiscService misc, RandomService rand, InteractiveService inter)
 {
     _commands = commands;
     _misc     = misc;
     _rand     = rand;
     _inter    = inter;
 }
Example #4
0
 public HelpCommand(CommandService commands, MiscService misc, IServiceProvider services, InteractiveService inter)
 {
     _commands = commands;
     _misc     = misc;
     _services = services;
     _inter    = inter;
 }
Example #5
0
        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 ? "删除成功" : "删除失败"));
        }
Example #6
0
 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);
 }
Example #8
0
 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, "发布失败"));
        }
Example #10
0
 static ServiceHelper()
 {
     Workshop = new WorkshopService();
     Student  = new StudentService();
     Booking  = new BookingService();
     Misc     = new MiscService();
     Task.Factory.StartNew(HelpsService.Purge);
 }
Example #11
0
        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, "发布失败"));
        }
Example #12
0
        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));
        }
Example #13
0
        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));
        }
Example #14
0
 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;
 }
Example #15
0
        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));
        }
Example #16
0
        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));
        }
Example #17
0
        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));
        }
Example #18
0
        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));
        }
Example #19
0
        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));
        }
Example #20
0
        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)));
        }
Example #21
0
        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));
        }
Example #22
0
        public ActionResult Index(int id)
        {
            Misc misc = MiscService.GetById(id);

            if (misc is null)
            {
                return(RedirectToAction("Index", "Error"));
            }
            return(View(misc));
        }
Example #23
0
 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>()));
        }
Example #25
0
        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, "发布失败"));
        }
Example #26
0
        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 ? "修改成功" : "修改失败"));
        }
Example #27
0
        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 ? "修改成功" : "修改失败"));
        }
Example #28
0
        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 ? "修改成功" : "修改失败"));
        }
Example #29
0
        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>()));
        }
Example #30
0
        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));
        }