Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        public string Add(PhoneInputModel phoneInputModel)
        {
            Phone phone = new Phone()
            {
                PhoneNumber = phoneInputModel.PhoneNumber
            };

            this.db.Phones.Add(phone);
            this.db.SaveChanges();

            return(phone.Id);
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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"));
        }
Exemplo n.º 7
0
        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 }));
        }