// private static PatientDto PatientToDTO(Patient patient) => //new PatientDto //{ // PatientDtoId = patient.PatientId, // Name = patient.Name, // Age = patient.Age, // Gender = patient.Gender, // Phone = patient.Phone, // AadharId = patient.AadharId //}; public async Task <HospitalDto> PostHospitalAsync(HospitalDto hospitalDto) { var hospital = new Hospital { Name = hospitalDto.Name, Phone = hospitalDto.Phone, StreetNo = hospitalDto.StreetNo, Area = hospitalDto.Area, City = hospitalDto.Area, State = hospitalDto.State, Country = hospitalDto.Country, Pincode = hospitalDto.Pincode }; _context.Hospital.Add(hospital); await _context.SaveChangesAsync(); var value = new HospitalDto { HospitalDtoId = hospital.HospitalId, Name = hospital.Name, Phone = hospital.Phone, StreetNo = hospital.StreetNo, Area = hospital.Area, City = hospital.City, State = hospital.State, Country = hospital.Country, Pincode = hospital.Pincode }; return(value); }
public void UpdateHospital(HospitalDto Hospital) { var model = _hospitalMapper.Map <Hospital>(Hospital); _unitOfWork.Hospitals.Update(model); _unitOfWork.Save(); }
public async Task <ActionResult <IEnumerable <HospitalDto> > > GetFastestHospitals([FromQuery] FastestQueryDto query) { var client = _clientFactory.CreateClient("dmmw"); var _hospitals = (await DmmwHelper.GetEmbeddedList <HospitalModel>(client, "hospitals")); List <HospitalDto> hospitals = new List <HospitalDto>(); foreach (var hospital in _hospitals) { WaitingModel waiting = hospital.WaitingList .Where(w => w.LevelOfPain == query.LevelOfPain.Value) .Single(); int waitingTime = waiting.PatientCount * waiting.AverageProcessTime; HospitalDto _hospital = new HospitalDto { Id = hospital.Id, Name = hospital.Name, LevelOfPain = query.LevelOfPain.Value, AverageProcessTime = waiting.AverageProcessTime, PatientCount = waiting.PatientCount, WaitingTime = waitingTime, Location = hospital.Location }; hospitals.Add(_hospital); } return(hospitals.OrderBy(h => h.WaitingTime).ToList()); }
public HospitalDto AddHospital(HospitalDto hospitalDto) { var hospitals = new Hospital() { HospitalId = hospitalDto.HospitalId, HospitalName = hospitalDto.HospitalName, Contact = hospitalDto.Contact, }; Context.Hospitals.Add(hospitals); Context.SaveChanges(); int hospitalId = hospitals.HospitalId; Address addr = new Address() { AddressId = hospitalDto.AddressId, AddressType = hospitalDto.AddressType, StreetNo = hospitalDto.StreetNo, Area = hospitalDto.Area, City = hospitalDto.City, State = hospitalDto.State, Country = hospitalDto.Country, ZipCode = hospitalDto.ZipCode, }; Context.Addresses.Add(addr); Context.SaveChanges(); return(hospitalDto); }
public async Task <IList <HospitalDto> > GetAllAsync() { var hospitalsDto = new List <HospitalDto>(); var hospitals = await _context.Hospital.ToListAsync(); foreach (var item in hospitals) { var hospitalDto = new HospitalDto(); hospitalDto.HospitalDtoId = item.HospitalId; hospitalDto.Name = item.Name; hospitalDto.Phone = item.Phone; hospitalDto.StreetNo = item.StreetNo; hospitalDto.Area = item.Area; hospitalDto.City = item.City; hospitalDto.State = item.State; hospitalDto.Country = item.Country; hospitalDto.Pincode = item.Pincode; hospitalsDto.Add(hospitalDto); } return(hospitalsDto); //return await _context.Patient //.Select(x => PatientToDTO(x)) //.ToListAsync(); }
private static void UpdateExistingHospitalFields(Guid id, HospitalDto hospitalDto, PersistenceClassesDataContext dataContext) { var hospital = dataContext.Hospitals.FirstOrDefault(p => p.Guid.Equals(id)); if (hospital == null) { throw GetResponseException(HttpStatusCode.NotFound, Messages.HospitalDoesNotExist); } if (hospitalDto.Name != null) { hospital.Name = hospitalDto.Name; } if (hospitalDto.Owner != null) { hospital.Owner = hospitalDto.Owner; } if (hospitalDto.MobilePhone != null) { hospital.MobilePhone = hospitalDto.MobilePhone; } if (hospitalDto.Address != null) { hospital.Address = hospitalDto.Address; } dataContext.SubmitChanges(); }
private static Hospital CreateHospital(HospitalDto hospitalDto, SysUser sysUser) { var hospital = Mapper.Map <HospitalDto, Hospital>(hospitalDto); hospital.Guid = Guid.Empty; hospital.UserId = sysUser.Guid; return(hospital); }
public HospitalDto CreateHospital(HospitalDto Hospital) { var model = _hospitalMapper.Map <Hospital>(Hospital); _unitOfWork.Hospitals.Create(model); _unitOfWork.Save(); return(_hospitalMapper.Map <HospitalDto>(model)); }
//public void AddHospital([FromBody] Hospital hospital) => hospitalRepository.Add(hospital); public ActionResult <HospitalDto> PostHospital(HospitalDto hospitalDto) { if (!ModelState.IsValid) { return(BadRequest("Invalid Data")); } hospitalRepository.AddHospital(hospitalDto); return(Ok("Success")); }
public void UpdateExistingHospital(Guid id, [FromBody] HospitalDto hospitalDto) { EnsureNotInRole(User, UserRole.Patient, Messages.OnlyAdministratorCanExecute); EnsureNotInRole(User, UserRole.Doctor, Messages.OnlyAdministratorCanExecute); if (IsUserInRole(User, UserRole.Hospital)) { EnsureId(User, id, Messages.HospitalNotAllowedToModifyOtherHospitals); } Execute(dataContext => UpdateExistingHospitalFields(id, hospitalDto, dataContext)); }
public async Task PostHospitalAsync(HospitalDto hospitalDto) { var hospital = new Hospital { Name = hospitalDto.Name, Phone = hospitalDto.Phone, StreetNo = hospitalDto.StreetNo, Area = hospitalDto.Area, City = hospitalDto.Area, State = hospitalDto.State, Country = hospitalDto.Country, Pincode = hospitalDto.Pincode }; _context.Hospital.Add(hospital); await _context.SaveChangesAsync(); }
public async Task UpdateHospitalAsync(int id, HospitalDto hospitalDto) { var hospital = await _context.Hospital.FirstOrDefaultAsync(x => x.HospitalId == id); if (hospital != null) { hospital.Name = hospitalDto.Name; hospital.Phone = hospitalDto.Phone; hospital.StreetNo = hospitalDto.StreetNo; hospital.Area = hospitalDto.Area; hospital.City = hospitalDto.City; hospital.State = hospitalDto.State; hospital.Country = hospitalDto.Country; hospital.Pincode = hospitalDto.Pincode; _context.Hospital.Update(hospital); await _context.SaveChangesAsync(); } }
public UserCredentialsDto CreateNewHospital([FromBody] HospitalDto hospitalDto) { EnsureInRole(User, UserRole.Admin, Messages.OnlyAdministratorCanExecute); var sysUser = CreateNewSysUser(UserRole.Hospital); Execute(dataContext => { dataContext.SysUsers.InsertOnSubmit(sysUser); dataContext.SubmitChanges(); }); var hospital = CreateHospital(hospitalDto, sysUser); Execute(dataContext => { dataContext.Hospitals.InsertOnSubmit(hospital); dataContext.SubmitChanges(); }); return(new UserCredentialsDto(sysUser)); }
public async Task <HospitalDto> GetHospitalAsync(int id) { var hospitalDto = new HospitalDto(); var hospital = await _context.Hospital.FirstOrDefaultAsync(x => x.HospitalId == id); if (hospital != null) { hospitalDto.HospitalDtoId = hospital.HospitalId; hospitalDto.Name = hospital.Name; hospitalDto.Phone = hospital.Phone; hospitalDto.StreetNo = hospital.StreetNo; hospitalDto.Area = hospital.Area; hospitalDto.City = hospital.City; hospitalDto.State = hospital.State; hospitalDto.Country = hospital.Country; hospitalDto.Pincode = hospital.Pincode; } return(hospitalDto); //var patient = await _context.Patient.FindAsync(id); //return PatientToDTO(patient); }
public async Task <IActionResult> PostHospitalAsync(HospitalDto hospitalDto) { await _hospitalService.PostHospitalAsync(hospitalDto); return(Ok()); }
public async Task <IActionResult> UpdateHospitalAsync(int id, HospitalDto hospitalDto) { await _hospitalService.UpdateHospitalAsync(id, hospitalDto); return(Ok()); }
public Task UpdateHospitalAsync(int id, HospitalDto hospitalDto) { throw new NotImplementedException(); }
public async Task <IActionResult> PostPatientAsync(HospitalDto hospitalDto) { return(Ok(await _hospitalService.PostHospitalAsync(hospitalDto))); }
public Task PostHospitalAsync(HospitalDto hospitalDto) { throw new NotImplementedException(); }