public JsonResult SeedBanks([FromBody] List <BankViewModel> banks) { BaseResponse response = new BaseResponse(); try { List <CountryViewModel> countries = countryService.GetCountries(banks.FirstOrDefault()?.Company?.Id ?? 0).Countries; foreach (var item in banks ?? new List <BankViewModel>()) { string mark = item?.Country.Mark; if (mark == "NEM" || mark == "GER" || mark == "DEU") { mark = "DEU"; } if (mark == "SRB" || mark == "RS") { mark = "SRB"; } item.Country = countries.FirstOrDefault(x => x.Mark == mark); bankService.Create(item); } } catch (Exception ex) { response = null; Console.WriteLine(ex.Message); } return(Json(response, new Newtonsoft.Json.JsonSerializerSettings() { Formatting = Newtonsoft.Json.Formatting.Indented })); }
//Creates a bank public void CreateBank() { Bank newBank = new Bank(); string input = string.Empty; //Asks for name while (input == string.Empty) { Console.WriteLine("Enter name of new bank:"); input = Console.ReadLine(); } newBank.Name = input; input = String.Empty; //Asks for BIC code (should be automatically generated I think, but isn't here for simplicity) while (input == string.Empty) { Console.WriteLine("Enter BIC of new bank:"); input = Console.ReadLine(); } newBank.Bic = input; //Create var createdBank = _bankService.Create(newBank); Console.WriteLine(createdBank.Name); }
public ActionResult CreateAccount(CreateAccountViewModel account) { _service.Create(new BankAccount() { TypeOfBillId = account.TypeOfBillId, Amount = account.Amount, ClientId = account.ClientId }); return(RedirectToAction("Index")); }
public ActionResult Create(BankCreateInput input) { if (!ModelState.IsValid) { return(View(input)); } bankService.Create((Bank) new Bank().InjectFrom(input)); return(Content("ok")); }
public async Task <IActionResult> Create([FromForm] CreateBankDto dto) { try { var bank = await _bankService.Create(dto); return(Created("Ok", _mapper.Map <Bank, BankToReturn>(bank))); } catch (Exception e) { return(BadRequest(new ApiException(StatusCodes.Status400BadRequest, e.Message))); } }
public void Create() { Console.WriteLine("Input bank name: "); string name = Console.ReadLine(); Console.WriteLine("Input bank BIC: "); string bic = Console.ReadLine(); Bank newBank = new Bank() { Name = name, BIC = bic }; _bankService.Create(newBank); }
public HttpResponseMessage AddBank([FromBody] BankEntity bank) { var entity = new BankEntity { Addtime = DateTime.Now, Codeid = bank.Codeid }; try { if (_bankService.Create(entity) != null) { return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!"))); } } catch { return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!"))); } return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!"))); }
public ActionResult Create(BankViewModel account) { _log.Info("Create Post"); if (!ModelState.IsValid) { return(View(account)); } try { _log.Info("Create account"); account.UserId = User.Identity.GetUserId(); _service.Create(account); return(RedirectToAction("List")); } catch (Exception e) { _log.Error("Error creating account: ", e); throw; } }
public async Task <ActionResult <BankDto> > Create(ShortBankDto bank) { try { var validationResult = await _validationDecorator.ValidateAsyncEx(bank); if (!validationResult.Result) { return(BadRequest(validationResult.Errors)); } var result = await _bankService.Create(description : bank.Description, bic : bank.Bic, corrAccount : bank.CorrAccount); return(CreatedAtAction(nameof(Get), new { id = result.Id }, _mapper.Map <BankDto>(result))); } //TODO append error handler middleware. Also append logging! catch { return(StatusCode(500)); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { #region Validation if (String.IsNullOrEmpty(CurrentBank.Name)) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Ime_banke")); return; } #endregion Thread th = new Thread(() => { SaveButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SaveButtonEnabled = false; CurrentBank.IsSynced = false; CurrentBank.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentBank.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; BankResponse response = bankService.Create(CurrentBank); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_čuvanja_na_serveruUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; BankCreatedUpdated(); if (IsCreateProcess) { CurrentBank = new BankViewModel(); CurrentBank.Identifier = Guid.NewGuid(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtSwift.Focus(); }) ); } else { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { if (IsPopup) { FlyoutHelper.CloseFlyoutPopup(this); } else { FlyoutHelper.CloseFlyout(this); } }) ); } } }); th.IsBackground = true; th.Start(); txtName.Focus(); }
public ActionResult <Bank> Post(Bank bank) { var newBank = _bankService.Create(bank); return(new JsonResult(newBank)); }