public IHttpActionResult Create(CreateAccountBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = User.Identity.GetUserId(); var houseHold = db.Households .FirstOrDefault(p => p.Id == model.HouseHoldId); if (houseHold == null) { return(BadRequest("HouseHold doesn't exist")); } if (houseHold.CreatorId == userId || houseHold.Members.Any(p => p.Id == userId)) { var bankAccount = new Accounts(); bankAccount.Name = model.Name; bankAccount.HouseHoldId = model.HouseHoldId; bankAccount.Balance = 0; db.Accounts.Add(bankAccount); db.SaveChanges(); return(Ok()); } else { return(BadRequest("Not authorized")); } }
// POST: Create an Account with specific role and password public IHttpActionResult PostAccount(CreateAccountBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } IdentityResult result = UserManager.Create(model.Account, model.Password); if (!result.Succeeded) { return(GetErrorResult(result)); } UserManager.AddToRole(model.Account.Id, model.RoleName); return(Ok()); }
public IHttpActionResult CreateAccount(CreateAccountBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Account account = new Account() { Account_id = model.Account_id, Account_name = model.Account_name, Account_global_email = model.Account_global_email, Account_brand_logo = model.Account_brand_logo }; int response = _accountLog.AccountInsert(account); if (response == 1) { return(Ok("Account has been added")); } else { return(BadRequest("There was some error please try again.")); } //var account = new Account() { Account_id = model.Account_id, Account_global_email = model.Account_global_email, Account_name = model.Account_name, Account_brand_logo=model.Account_brand_logo }; // return Ok(); }
private void LogIfFailed(MyValidator validator, CreateAccountBindingModel obj)) {