public async Task <IActionResult> Create([Bind("Guid,UserName,Password,Role,Email,CreateTime,UpdateTime")] Account account) { if (ModelState.IsValid) { account.Guid = Guid.NewGuid(); account.CreateTime = DateTime.Now; account.UpdateTime = DateTime.Now; account.Role = UserRole.Ordinary; context.Add(account); await context.SaveChangesAsync(); var partyMember = new PartyMember(new SeriaNumber().Seria(pMContext.PartyMembers.Count() + 1, Key.PMPre)) { Guid = Guid.NewGuid(), CreateTime = DateTime.Now, UpdateTime = DateTime.Now }; pMContext.Add(partyMember); await pMContext.SaveChangesAsync(); var accountPartyMember = new AccountPartyMember(account.UserName, partyMember.PartyMemberID) { Guid = Guid.NewGuid(), CreateTime = DateTime.Now, UpdateTime = DateTime.Now }; aPMContext.Add(accountPartyMember); await aPMContext.SaveChangesAsync(); var partyCost = new PartyCost(new SeriaNumber().Seria(pCContext.PartyCosts.Count() + 1, Key.PCPre), partyMember.PartyMemberID) { Guid = Guid.NewGuid(), CreateTime = DateTime.Now, UpdateTime = DateTime.Now, State = Verify.Unaudited }; pCContext.Add(partyCost); await pCContext.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(account)); }
public async Task <IActionResult> Create([Bind(PKey.PMPram)] PartyMember partyMember) { if (ModelState.IsValid) { partyMember.Guid = Guid.NewGuid(); partyMember.CreateTime = DateTime.Now; partyMember.UpdateTime = DateTime.Now; partyMember.PartyMemberID = new SeriaNumber().Seria(context.PartyMembers.Count() + 1, Key.PMPre); partyMember.Stage = PartyMember.DevelopmentStage.NotInput; context.Add(partyMember); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(partyMember)); }