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)); }
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)); }