예제 #1
0
        public async Task <IHttpActionResult> PutPatient(int id, Patient patient)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != patient.Id)
            {
                return(BadRequest());
            }

            db.Entry(patient).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PatientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public HelperRequest UpdateDoctor(UpdateDoctorRequest request)
        {
            var helper = new HelperRequest();

            var countDoctor = _context.Doctors.Count(doc =>
                                                     doc.LastName == request.LastName && doc.FirstName == request.FirstName);

            if (countDoctor == 0)
            {
                helper.Number = 0;
                return(helper);
            }

            var doctor = new Doctor
            {
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Email     = request.Email,
            };

            _context.Attach(doctor);
            _context.Entry(doctor).Property("FirstName").IsModified = true;
            _context.Entry(doctor).Property("LastName").IsModified  = true;
            _context.Entry(doctor).Property("Email").IsModified     = true;

            _context.SaveChangesAsync();

            helper.Number = 1;

            return(helper);
        }
예제 #3
0
        public async Task <int> CreateDoctor(CreateDoctorViewModel model)
        {
            var doctor = new Doctor
            {
                Name           = model.Name,
                Surname        = model.Surname,
                Email          = model.Email,
                Phone          = model.Phone,
                Specialization = (Specialization)Enum.Parse(typeof(Specialization), model.Specialization),
            };

            try
            {
                await _dbContext.Doctors.AddAsync(doctor);

                await _dbContext.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new ClinicException(ErrorCodes.SavingChangesError, ex);
            }


            return(doctor.Id);
        }
      public async Task <Doctor> AddDoctor(Doctor doctor)
      {
          var doctorEntity = await _dbContext.Doctors.AddAsync(doctor);

          await _dbContext.SaveChangesAsync();

          return(doctorEntity.Entity);
      }
        public async Task <IActionResult> Create([Bind("Id,Name,Price")] Checkup checkup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(checkup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(checkup));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Desc,Photo")] DiaqnosticServis diaqnosticServis)
        {
            if (ModelState.IsValid)
            {
                _context.Add(diaqnosticServis);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(diaqnosticServis));
        }
예제 #7
0
        public async Task <IActionResult> Create([Bind("Id,Title,Icon,Desc")] Promo promo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(promo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(promo));
        }
        public async Task <IActionResult> Create([Bind("Id,Time,Date")] ClinicOpeningHours clinicOpeningHours)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clinicOpeningHours);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clinicOpeningHours));
        }
예제 #9
0
        public async Task <IActionResult> Create([Bind("Id,PasientName,Time,Email,Date,Message,DepartmentsId")] Randevu randevu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(randevu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentsId"] = new SelectList(_context.Departments, "Id", "Id", randevu.DepartmentsId);
            return(View(randevu));
        }
예제 #10
0
        public async Task <IActionResult> Create([Bind("Id,Date,Time,DoctorId")] DoctorOpeningHours doctorOpeningHours)
        {
            if (ModelState.IsValid)
            {
                _context.Add(doctorOpeningHours);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"] = new SelectList(_context.Doctors, "Id", "Id", doctorOpeningHours.DoctorId);
            return(View(doctorOpeningHours));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Icon,Url,DoctorId")] DoctorTeamLink doctorTeamLink)
        {
            if (ModelState.IsValid)
            {
                _context.Add(doctorTeamLink);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"] = new SelectList(_context.Doctors, "Id", "Id", doctorTeamLink.DoctorId);
            return(View(doctorTeamLink));
        }
      public async Task <IActionResult> Create([Bind("Id,Name,CheckupId")] CheckupSetting checkupSetting)
      {
          if (ModelState.IsValid)
          {
              _context.Add(checkupSetting);
              await _context.SaveChangesAsync();

              return(RedirectToAction(nameof(Index)));
          }
          ViewData["CheckupId"] = new SelectList(_context.Checkups, "Id", "Id", checkupSetting.CheckupId);
          return(View(checkupSetting));
      }
        public async Task <IActionResult> Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                User user = _context.User.FirstOrDefault(u => u.Email == model.Email);

                if (user != null)
                {
                    if (Crypto.VerifyHashedPassword(user.Password, model.Password))
                    {
                        user.Token = Crypto.HashPassword(DateTime.Now.ToString());
                        await _context.SaveChangesAsync();

                        Response.Cookies.Append("token", user.Token, new Microsoft.AspNetCore.Http.CookieOptions
                        {
                            Expires  = DateTime.Now.AddMinutes(30),
                            HttpOnly = true
                        });
                    }

                    return(RedirectToAction("index", "home"));
                }
            }

            return(View(model));
        }
 public async Task<IActionResult> Create([Bind("Id,Upload,Adress,OpenDate,ClosedDate,Email,Phone")] Settings settings)
 {
     if (settings.Upload == null)
     {
         ModelState.AddModelError("Uploads", "The Photo field is required.");
     }
     if (ModelState.IsValid)
     {
         var fileName = _fileManager.Upload(settings.Upload, "wwwroot/uploads/gallery");
         settings.Logo = fileName;
         _context.Add(settings);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(settings);
 }
예제 #15
0
        public async Task <IActionResult> Create([Bind("Id,Upload,Upload,Title,Desc,Date")] News news)
        {
            if (news.Upload == null)
            {
                ModelState.AddModelError("Uploads", "The Photo field is required.");
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(news.Upload, "wwwroot/uploads/gallery");
                news.Photo = fileName;
                _context.Add(news);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(news));
        }
예제 #16
0
        public async Task <IActionResult> Create([Bind("Id,Name,About,ShortAbout,Upload")] Diseas diseas)
        {
            if (diseas.Upload == null)
            {
                ModelState.AddModelError("Uploads", "The Photo field is required.");
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(diseas.Upload, "wwwroot/uploads/gallery");
                diseas.Photo = fileName;
                _context.Add(diseas);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(diseas));
        }
        public async Task <IActionResult> Create([Bind("Id,Desc,Upload,FullName,Position")] PatientSay patientSay)
        {
            if (patientSay.Upload == null)
            {
                ModelState.AddModelError("Uploads", "The Photo field is required.");
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(patientSay.Upload, "wwwroot/uploads/gallery");
                patientSay.Photo = fileName;
                _context.Add(patientSay);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(patientSay));
        }
        public async Task <IActionResult> Create([Bind("Id,About,Upload,Title,Desc")] WelcomeClinic welcomeClinic)
        {
            if (welcomeClinic.Upload == null)
            {
                ModelState.AddModelError("Uploads", "The Photo field is required.");
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(welcomeClinic.Upload, "wwwroot/uploads/main-slider");
                welcomeClinic.Photo = fileName;
                _context.Add(welcomeClinic);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(welcomeClinic));
        }
예제 #19
0
        public async Task <IActionResult> Create([Bind("Id,FullName,Education,Speciality,Experience,Address,Timing,Phone,Email,Website,About,Upload,Position,DepartmentsId,IsHome")] Doctor doctor)
        {
            if (doctor.Upload == null)
            {
                ModelState.AddModelError("Uploads", "The Photo field is required.");
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(doctor.Upload, "wwwroot/uploads/gallery");
                doctor.Photo = fileName;
                _context.Add(doctor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentsId"] = new SelectList(_context.Departments, "Id", "Id", doctor.DepartmentsId);
            return(View(doctor));
        }
예제 #20
0
        public Doctor RemoveDoctor(int id)
        {
            var doctor = GetDoctor(id);

            if (doctor == null)
            {
                return(null);
            }
            _dbContext.Doctors.Remove(doctor);
            _dbContext.SaveChangesAsync();
            return(doctor);
        }
예제 #21
0
        /// <summary>
        /// Add a patient to the database
        /// </summary>
        /// <param name="patient">A patient to be added to the database</param>
        public async Task <Models.Patient> AddPatientAsync(Models.Patient patient)
        {
            if (patient.PrimaryDoctor is null)
            {
                var dr        = _context.Doctors.First();
                var patientdr = new Domain.Models.Doctor(dr.Id, dr.Name);
                patient.PrimaryDoctor = patientdr;
            }
            var newPatient = new DataModel.Patient
            {
                Name      = patient.Name,
                Dob       = patient.DateOfBirth,
                DoctorId  = patient.PrimaryDoctor.Id,
                Ssn       = patient.SSN,
                Insurance = patient.InsuranceProvider
            };
            await _context.Patients.AddAsync(newPatient);

            await _context.SaveChangesAsync();

            patient.Id = newPatient.Id;
            return(patient);
        }