Exemple #1
0
        public async Task Create(DoctorEditDto doctor)
        {
            await appDbContext.AddAsync(new Doctor
            {
                FirstName = doctor.FirstName,
                LastName  = doctor.LastName,
                Email     = doctor.Email,
            });

            await appDbContext.SaveChangesAsync();
        }
Exemple #2
0
        public async Task <IActionResult> Edit([FromQuery] int id, [FromBody] DoctorEditDto doctor)
        {
            try
            {
                await doctorRepository.Update(id, doctor);

                return(Ok());
            }
            catch (Exception e) when(e is NullReferenceException)
            {
                return(NotFound());
            }
        }
Exemple #3
0
        public async Task Update(int id, DoctorEditDto doctor)
        {
            var firstAsync = await appDbContext.Doctors.FirstOrDefaultAsync(n => n.IdDoctor == id);

            if (firstAsync == null)
            {
                throw new NullReferenceException();
            }

            firstAsync.LastName  = doctor.LastName;
            firstAsync.FirstName = doctor.FirstName;
            firstAsync.Email     = doctor.Email;

            await appDbContext.SaveChangesAsync();
        }
        public bool Edit(DoctorEditDto doctor)
        {
            if (doctor != null)
            {
                var doc = new Doctor();
                doc.Id    = doctor.Id;
                doc.Name  = doctor.Name;
                doc.Phone = doctor.Phone;
                _doctorRepository.Edit(doc);
                _unitOfWork.Complete();

                return(true);
            }

            return(false);
        }
Exemple #5
0
        public async Task <IActionResult> Create(DoctorEditDto doctor)
        {
            await doctorRepository.Create(doctor);

            return(Ok());
        }