public IActionResult Create(AccountView accountView, IFormFile photo) { if (ModelState.IsValid && photo != null && photo.FileName.Length > 0) { var filename = SaveFile.SaveImage(photo, "Admin\\images\\Account", IWebhost).Result; if (filename == null) { return(View("0")); } accountView.Image = filename; var result = _IAcc.CreateAccount(accountView); if (result != null) { ViewBag.photo = photo.FileName; ViewBag.result = 1; } else { SaveFile.Remove(filename, "Admin\\images\\Account", IWebhost); ViewBag.result = 0; } } return(View(accountView)); }
public async void Register(NetworkStream stream, string content) { AccountModel dummy = JsonSerializer.Deserialize <AccountModel>(content); string input = await _accountRepo.CreateAccount(dummy); string reply = JsonSerializer.Serialize(input); byte[] bytesWrite = Encoding.ASCII.GetBytes(reply); stream.Write(bytesWrite, 0, bytesWrite.Length); }
public ActionResult <AccountReadDto> CreateAccount(AccountCreateDto accountCreateDto) { var accountModel = _mapper.Map <Account>(accountCreateDto); _repository.CreateAccount(accountModel); _repository.SaveChanges(); var accountReadDto = _mapper.Map <AccountReadDto>(accountModel); return(CreatedAtRoute(nameof(GetAccountById), new { ID = accountReadDto.ID }, accountReadDto)); }
public ActionResult <AccountReadDto> CreateAccount([FromBody] AccountCreateDto accountCreateDto) { var accountModel = _mapper.Map <Accounts>(accountCreateDto); accountModel.ApiKey = KeyGenerator.GetUniqueKey(128); accountModel.CreateDate = DateTime.Now; while (!_repository.ValidateNewKey(accountModel.ApiKey)) { accountModel.ApiKey = KeyGenerator.GetUniqueKey(128); } _repository.CreateAccount(accountModel); _repository.SaveChanges(); var accountReadDto = _mapper.Map <AccountReadDto>(accountModel); return(CreatedAtAction(nameof(CreateAccount), accountReadDto)); }
public ActionResult <AccountRead> CreateAccount(AccountCreate accountCreate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var AccAmt1 = accountCreate.Salary - accountCreate.Expenses; if (AccAmt1 < 1000) { return(StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status204NoContent, "Not Created")); } var account = _mapper.Map <Account>(accountCreate); _reprositry.CreateAccount(account); _reprositry.SaveChanges(); var accountRead = _mapper.Map <AccountRead>(account); return(Created("Account Creaated", account)); }
public int Create(AccountDto accountDto) { return(_accountRepo.CreateAccount(accountDto)); }