public IActionResult Add([FromRoute] int id) { AddPhoneViewModel model = new AddPhoneViewModel(); model.PersonId = id; return(View(model)); }
public ActionResult AddPhone(AddPhoneViewModel model) { using (var db = Db4oEmbedded.OpenFile(path)) { var telefon1 = db.Query<Telefon>(x => x.NumerTelefonu == model.NumerTelefonu).ToList(); if (ModelState.IsValid && telefon1.Count == 0) { var student = db.Query<Student>(x => x.StudentId == model.StudentId).First(); student.Telefon.Add(new Telefon { CzyKomorkowy = model.CzyKomorkowy, NazwaOperatora = model.NazwaOperatora, NumerTelefonu = model.NumerTelefonu }); db.Store(student.Telefon); db.Commit(); return RedirectToAction("Szczegoly", new { id = model.StudentId }); } if (telefon1.Count != 0) { ModelState.AddModelError("NumerTelefonu", "taki nr telefonu już istnieje"); } } return View(model); }
public IActionResult Add(AddPhoneViewModel model, [FromRoute] int id) { if (ModelState.IsValid) { Phone phone = new Phone { phoneNumber = model.Number, PhoneType = model.Type, phoneId = id }; PhoneRepo.Add(phone); return(RedirectToAction("Detail", "People")); } else { return(View(model)); } }
public IActionResult Add(AddPhoneViewModel model) { if (ModelState.IsValid) { Phone phone = new Phone { PersonId = model.PersonId, PhoneNumber = model.Number, PhoneType = model.Type }; _phoneRepository.Add(phone); return(RedirectToAction("Details", "People", new { id = phone.PersonId })); } else { return(View(model)); } }
public async Task <IActionResult> AddPhone(AddPhoneViewModel model) { if (!ModelState.IsValid) { return(View(model)); } // Generate the token and send it var user = await GetCurrentUserAsync(); if (user == null) { return(View("Error")); } var token = await _userManager.GenerateChangePhoneNumberTokenAsync(user, model.Phone); await _userManager.ChangePhoneNumberAsync(user, model.Phone, token); return(RedirectToAction(nameof(Index), new { Message = ManageMessageId.AddPhoneSuccess })); }
public AddPhoneView() { InitializeComponent(); DataContext = new AddPhoneViewModel(); }