public async Task <IActionResult> Create([Bind("FirstName,MiddleName,LastName,BirthDate,Gender,CitizenshipId,Number,IdentificationNumber,IssuingAuthorityId,IssuingAuthorityLocalityId,IssueDate,ExpirationDate,Citizenship,Id")] Passport passport) { if (ModelState.IsValid) { _context.Add(passport); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } var localities = await localityRepository.GetBy().ToListAsync(); ViewBag.Localities = localities.Select(a => new SelectListItem($"{a.Region} {a.LocalityName}", a.Id.ToString())); var firstLocality = localities.FirstOrDefault(); if (firstLocality != null) { var issuingAuthorityLocalities = await issuingAuthorityLocalityRepository.GetBy(a => a.LocalityId == firstLocality.Id, a => a.IssuingAuthority).ToListAsync(); ViewBag.IssuingAuthorities = issuingAuthorityLocalities .Select(a => new SelectListItem(a.IssuingAuthority.Name, a.IssuingAuthority.Id.ToString())); } ViewBag.Citizenships = CitizenshipConsts.Dict.Select(c => new SelectListItem(c.Value, c.Key.ToString())); return(View(passport)); }
public async Task <IActionResult> Create([Bind("DepositName,PaymentPeriod,DepositTermId,Rate,AccountReplenishment,Currency,Id")] Deposit deposit) { if (ModelState.IsValid) { _context.Add(deposit); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.DepositTerms = _context.DepositTerms.ToList().Select((d) => { if (d.DaysAmount != 0) { return(new SelectListItem($"{d.DaysAmount.ToString()} дней", d.Id.ToString())); } else if (d.MonthsAmount != 0) { return(new SelectListItem($"{d.MonthsAmount.ToString()} месяцев", d.Id.ToString())); } return(new SelectListItem($"{d.YearsAmount.ToString()} лет", d.Id.ToString())); }); ViewBag.Currencies = CurrencyConsts.Dict.Select(s => new SelectListItem(s.Value, s.Key.ToString())); return(View(deposit)); }
public async Task <IActionResult> Create([Bind("DaysAmount,MonthsAmount,YearsAmount,Id")] DepositTerm depositTerm) { if (ModelState.IsValid) { _context.Add(depositTerm); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(depositTerm)); }
public async Task <IActionResult> Create([Bind("Name,Id")] IssuingAuthority issuingAuthority) { if (ModelState.IsValid) { _context.Add(issuingAuthority); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(issuingAuthority)); }
public async Task <IActionResult> Create([Bind("Operator,Id")] PhoneNumberOperator phoneNumberOperator) { if (ModelState.IsValid) { _context.Add(phoneNumberOperator); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(phoneNumberOperator)); }
public async Task <IActionResult> Create([Bind("LocalityId,StreetName,Postcode,Id")] Street street) { if (ModelState.IsValid) { _context.Add(street); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["LocalityId"] = new SelectList(_context.Localities, "Id", "LocalityName", street.LocalityId); return(View(street)); }
public async Task <IActionResult> Create([Bind("OpeningDate,ClosingDate,Amount,Currency,Id")] Account account) { if (ModelState.IsValid) { _context.Add(account); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.Currencies = CurrencyConsts.Dict.Select(s => new SelectListItem(s.Value, s.Key.ToString())); return(View(account)); }
public async Task <IActionResult> Create([Bind("Region,LocalityName,LocalityType,Id")] Locality locality) { if (ModelState.IsValid) { locality.Region = locality.Region ?? ""; _context.Add(locality); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(locality)); }
public async Task <IActionResult> Create([Bind("StreetId,House,Housing,Apartment,Id")] Address address) { if (ModelState.IsValid) { _context.Add(address); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["StreetId"] = new SelectList(_context.Streets, "Id", "StreetName", address.StreetId); return(View(address)); }
public async Task <IActionResult> Create([Bind("PhoneNumberOperatorId,Code")] PhoneNumberOperatorCode phoneNumberOperatorCode) { if (ModelState.IsValid) { _context.Add(phoneNumberOperatorCode); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PhoneNumberOperatorId"] = new SelectList(_context.PhoneNumberOperators, "Id", "Operator", phoneNumberOperatorCode.PhoneNumberOperatorId); return(View(phoneNumberOperatorCode)); }
public async Task <IActionResult> Create([Bind("IssuingAuthorityId,LocalityId")] IssuingAuthorityLocality issuingAuthorityLocality) { if (ModelState.IsValid) { _context.Add(issuingAuthorityLocality); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IssuingAuthorityId"] = new SelectList(_context.IssuingAuthorities, "Id", "Name", issuingAuthorityLocality.IssuingAuthorityId); ViewData["LocalityId"] = new SelectList(_context.Localities, "Id", "LocalityName", issuingAuthorityLocality.LocalityId); return(View(issuingAuthorityLocality)); }
public async Task <IActionResult> Create([Bind("PassportId,AddressId,PhoneNumberId,Email,Id")] Depositor depositor) { if (ModelState.IsValid) { _context.Add(depositor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.Addresses = _context.Addresses.Include(s => s.Street).Select(s => new SelectListItem($"{s.Street.Locality.LocalityName} {s.Street.StreetName} {s.House} {s.Housing}", s.Id.ToString())); ViewBag.Passports = _context.Passports.Select(s => new SelectListItem(s.FullName, s.Id.ToString())); ViewBag.PhoneNumbers = _context.PhoneNumbers.Include(s => s.Operator).Select(s => new SelectListItem($"{s.Operator.Operator} {s.OperatorCode} {s.Number}", s.Id.ToString())); return(View(depositor)); }
public async Task <IActionResult> Create([Bind("DepositId,DepositorId,EmployeeId,AccountId,ConclusionDate,TerminationDate,Id")] Contract contract) { if (ModelState.IsValid) { _context.Add(contract); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AccountId"] = new SelectList(_context.Accounts, "Id", "Id", contract.AccountId); ViewData["DepositId"] = new SelectList(_context.Deposits, "Id", "DepositName", contract.DepositId); ViewData["DepositorId"] = new SelectList(_context.Depositors, "Id", "Id", contract.DepositorId); ViewData["EmployeeId"] = new SelectList(_context.Employees, "Id", "Password", contract.EmployeeId); return(View(contract)); }
public async Task <IActionResult> Edit(Currency id, [Bind("Currency,Buy,AmountInNativeCurrencyPerUnit")] CurrencyConversion currencyConversion) { if (id != currencyConversion.Currency) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(currencyConversion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CurrencyConversionExists(currencyConversion.Currency)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(currencyConversion)); }
public async Task <IActionResult> DeleteConfirmed(int id) { var employee = await _context.Employees.FindAsync(id); _context.Employees.Remove(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("AccountId,DateTime,Amount,Type,Id")] AccountOperation accountOperation) { if (ModelState.IsValid) { _context.Add(accountOperation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AccountId"] = new SelectList(_context.Accounts, "Id", "Id", accountOperation.AccountId); return(View(accountOperation)); }