示例#1
0
        public async Task <IActionResult> Add([FromForm] AddUserModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var managerId = Guid.Parse(model.ManagerId);

            await _dataTarget.ProvisionAsync(new User
            {
                EmailAddress = model.EmailAddress,
                FullName     = model.FullName,
                PhoneNumber  = model.PhoneNumber,
                UserName     = model.UserName,
                Manager      = await _dataSource.Entities <User>()
                               .SingleOrDefaultAsync(x => x.Id == managerId)
            });

            return(RedirectToAction(nameof(Index)));
        }