Beispiel #1
0
        public async Task <IActionResult> EditBranch(int?cid, int?id)
        {
            Branch model;

            if (id == null)
            {
                if (cid == null)
                {
                    throw new Exception("必须传递cid参数");
                }
                var committee = await _committeeApi.GetCommittee(cid.Value);

                if (committee == null || committee.Id <= 0)
                {
                    throw new Exception("传递了无效的委员会主键");
                }

                //为委员会创建一个新的支部
                model = new Branch
                {
                    CommitteeId     = cid.Value,
                    Committee       = committee,
                    CurrentSequence = 1,
                    FoundDate       = DateTime.Today
                };
            }
            else
            {
                //编辑一个已有的支部信息
                model = await _committeeApi.GetBranch(id.Value);
            }

            return(View(model));
        }
Beispiel #2
0
        public async Task <IActionResult> Create(int?bid)
        {
            ViewBag.IsValid = true;

            var model = new Member();

            if (bid.HasValue)
            {
                model.Branch = await _committeeApi.GetBranch(bid.Value);

                model.BranchId = model.Branch == null ? 0 : model.Branch.Id;
            }

            ViewBag.CommitteeId = model.Branch?.CommitteeId;

            return(View(model));
        }