コード例 #1
0
        public ActionResult CreateAccount([FromBody] AccountCM model)
        {
            var result = _accountService.GetAccounts(a => a.User_Id.Equals(model.User_Id)).Where(s => !s.IsDelete);

            if (result.Count() > 0)
            {
                return(BadRequest("User_Id Has Been Exist"));
            }
            Account newAccount = model.Adapt <Account>();

            newAccount.IsDelete = false;
            _accountService.CreateAccount(newAccount);
            _accountService.Save();
            return(Ok(200));
        }
コード例 #2
0
        public async Task <ActionResult> CreateAccount([FromBody] AccountCM accountCM)
        {
            Account account = _mapper.Map <Account>(accountCM);

            try
            {
                account.IsBeautyArtist = false;
                await _accountService.AddAsync(account);

                await _accountService.Save();
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
            Account createAccount = await _accountService.AddAsync(account);

            await _accountService.Save();

            return(CreatedAtAction("GetAccountById", createAccount));
        }