Beispiel #1
0
        public async Task OnEdit(AppInputDto model)
        {
            var result = await DrawerSvr.CreateDialogAsync <AppEdit, string?, MessageModel <bool> >(model.Id, title : $"编辑应用 【{model.Name}】", width : 450);

            if (result != null && result.success)
            {
                await OnQuery();
            }
        }
Beispiel #2
0
        protected override async Task OnInitializedAsync()
        {
            isLoading = true;
            Console.WriteLine(base.Options);
            if (!string.IsNullOrEmpty(base.Options))
            {
                model  = (await Http.GetFromJsonAsync <AppInputDto>($"api/App/{base.Options}"));
                isEdit = true;
            }
            else
            {
                model  = new AppInputDto();
                isEdit = false;
            }
            await base.OnInitializedAsync();

            isLoading = false;
        }
Beispiel #3
0
        public async Task OnDelete(AppInputDto model)
        {
            if (await ConfirmSvr.Show($"是否删除任务 {model.Name}", "停止", ConfirmButtons.YesNo, ConfirmIcon.Question) == ConfirmResult.Yes)
            {
                var result = await Http.DeleteFromJsonAsync <MessageModel <bool> >($"api/app/{model.Id}");

                if (result.success)
                {
                    await OnQuery();

                    MsgSvr.Success($"{model.Name} 删除成功");
                }
                else
                {
                    MsgSvr.Error($"{model.Name} 删除失败,错误:{result.msg}");
                }
            }
        }
        public async Task <MessageModel <bool> > Add([FromBody] AppInputDto model)
        {
            MessageModel <bool> response = new MessageModel <bool>();

            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            var oldApp = await _appService.GetAsync(model.Id);

            if (oldApp != null)
            {
                return(new MessageModel <bool>()
                {
                    success = false,
                    msg = "应用Id已存在,请重新输入。"
                });
            }
            var app = new AppEntity();

            app.Id         = model.Id;
            app.Name       = model.Name;
            app.Enabled    = model.Enabled;
            app.CreateTime = DateTime.Now;
            app.UpdateTime = null;

            var result = await _appService.AddAsync(app);

            if (result)
            {
                response.success = true;
                response.msg     = "新增成功";
                return(response);
            }
            return(new MessageModel <bool>()
            {
                success = false,
                msg = !result ? "新建应用失败,请查看错误日志" : ""
            });
        }
        public async Task <MessageModel <bool> > Put(string id, [FromBody] AppInputDto model)
        {
            MessageModel <bool> response = new MessageModel <bool>();

            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var app = await _appService.GetAsync(model.Id);

            if (app == null)
            {
                return(new MessageModel <bool>()
                {
                    success = false,
                    msg = "未找到对应的应用程序。"
                });
            }
            app.Name       = model.Name;
            app.Enabled    = model.Enabled;
            app.UpdateTime = DateTime.Now;
            var result = await _appService.UpdateAsync(app);

            if (result)
            {
                response.success = true;
                response.msg     = "修改成功";
                return(response);
            }
            return(new MessageModel <bool>()
            {
                success = false,
                msg = !result ? "修改应用失败,请查看错误日志" : ""
            });
        }