public void AddPhone(string doctorId, PhoneInputModel phoneInputModel) { Doctor doctor = this.GetDoctor(doctorId); string phoneId = this.phonesService.Add(phoneInputModel); doctor.Phones.Add(this.phonesService.GetPhone(phoneId)); this.db.SaveChanges(); }
public void AddPhone(string personId, PhoneInputModel phoneInputModel) { Person person = this.GetPerson(personId); string phoneId = this.phonesService.Add(phoneInputModel); person.Phones.Add(this.phonesService.GetPhone(phoneId)); this.db.SaveChanges(); }
public void AddPhone(string relativeId, PhoneInputModel phoneInputModel) { Relative relative = this.GetRelative(relativeId); string phoneId = this.phonesService.Add(phoneInputModel); relative.Phones.Add(this.phonesService.GetPhone(phoneId)); this.db.SaveChanges(); }
public string Add(PhoneInputModel phoneInputModel) { Phone phone = new Phone() { PhoneNumber = phoneInputModel.PhoneNumber }; this.db.Phones.Add(phone); this.db.SaveChanges(); return(phone.Id); }
public IActionResult Edit(int id) { PhoneServiceModel phone = this.phonesService.GetById(id); if (phone.PhoneNumber == null) { return(this.BadRequest()); } var model = new PhoneInputModel { Id = phone.Id, PhoneNumber = phone.PhoneNumber, }; return(this.View(model)); }
public async Task <IActionResult> CreatePhone(PhoneInputModel model) { this.FillUnifiedModel(); if (!this.ModelState.IsValid) { return(this.View("Create", this.unifiedModel)); } var phone = new CreatePhoneServiceModel { PhoneNumber = model.PhoneNumber, }; await this.phonesService.CreateAsync(phone); return(this.RedirectToAction("Create")); }
public async Task <IActionResult> Edit(PhoneInputModel model) { if (!this.phonesService.Exists(model.Id)) { return(this.BadRequest()); } if (!ModelState.IsValid) { return(this.RedirectToAction("Error", "Home")); } EditPhoneServiceModel serviceModel = new EditPhoneServiceModel { Id = model.Id, PhoneNumber = model.PhoneNumber, }; await this.phonesService.EditAsync(serviceModel); return(this.RedirectToAction("Details", "Phones", new { id = serviceModel.Id })); }