Пример #1
0
        public async Task <IActionResult> TagEdit(long?id, long?AccountId)
        {
            if (id.HasValue)
            {
                //编辑
                var model = await tagService.GetByIdAsync(id.Value);

                if (model == null)
                {
                    throw new VinoDataNotFoundException("无法取得数据!");
                }
                model.Account = await accountService.GetByIdAsync(model.AccountId);

                if (model.Account == null)
                {
                    throw new VinoDataNotFoundException("数据出错!");
                }
                ViewData["Mode"] = "Edit";
                return(View(model));
            }
            else
            {
                //新增
                WxUserTagDto dto = new WxUserTagDto();
                if (AccountId.HasValue)
                {
                    dto.AccountId = AccountId.Value;
                    dto.Account   = await accountService.GetByIdAsync(AccountId.Value);

                    if (dto.Account == null)
                    {
                        throw new VinoDataNotFoundException("参数出错!");
                    }
                }
                else
                {
                    throw new VinoDataNotFoundException("参数出错!");
                }
                ViewData["Mode"] = "Add";
                return(View(dto));
            }
        }
Пример #2
0
        public async Task OnGetAsync(long?id, long?AccountId)
        {
            if (id.HasValue)
            {
                Dto = await _service.GetByIdAsync(id.Value);

                if (Dto == null)
                {
                    throw new KuDataNotFoundException();
                }
                Dto.Account = await _accountService.GetByIdAsync(Dto.AccountId);

                if (Dto.Account == null)
                {
                    throw new KuDataNotFoundException("数据出错!");
                }
                ViewData["Mode"] = "Edit";
            }
            else
            {
                Dto = new WxUserTagDto();
                if (AccountId.HasValue)
                {
                    Dto.AccountId = AccountId.Value;
                    Dto.Account   = await _accountService.GetByIdAsync(AccountId.Value);

                    if (Dto.Account == null)
                    {
                        throw new KuDataNotFoundException("参数出错!");
                    }
                }
                else
                {
                    throw new KuDataNotFoundException("参数出错!");
                }
                ViewData["Mode"] = "Add";
            }
        }
Пример #3
0
        public async Task <IActionResult> SaveTag(WxUserTagDto model)
        {
            await tagService.SaveAsync(model);

            return(JsonData(true));
        }