public async Task <IActionResult> Post([FromBody] DoctorDto doctor) { await _doctorService.AddDoctor(doctor.Email, doctor.Password, doctor.Pesel, doctor.FirstName, doctor.SecondName, doctor.PhoneNumber, doctor.PostCode, doctor.City, doctor.Street, doctor.HouseNumber); return(Created("/doctors/5", null)); }
public ActionResult AddDoctor(DoctorViewModel doctorViewModel) { if (ModelState.IsValid) { _doctorService.AddDoctor(doctorViewModel); return(Json(new { success = true })); } return(Json(new { success = false, error = ModelState.Values.FirstOrDefault(v => v.Errors?.Count > 0).Errors.FirstOrDefault()?.ErrorMessage })); }
public ActionResult AddDoctor(DoctorViewModel doctorViewModel) { if (ModelState.IsValid) { _doctorService.AddDoctor(doctorViewModel); return(RedirectToAction("Doctors")); } return(View(doctorViewModel)); }
/// <summary> /// Import doctors from XLSX file /// </summary> /// <param name="stream">Stream</param> /// <param name="userId"></param> /// <param name="iRow"></param> public virtual void ImportDoctorsFromXlsx(Stream stream, string userId, int iRow) { //property array var properties = new[] { new PropertyByName <Doctor>("FirstName"), new PropertyByName <Doctor>("LastName"), new PropertyByName <Doctor>("Email"), new PropertyByName <Doctor>("PhoneNumber"), new PropertyByName <Doctor>("Gender"), new PropertyByName <Doctor>("ShortProfile"), new PropertyByName <Doctor>("Qualifications"), new PropertyByName <Doctor>("YearsOfExperience"), new PropertyByName <Doctor>("RegistrationNumber"), new PropertyByName <Doctor>("DateOfBirth"), }; var manager = new PropertyManager <Doctor>(properties); using (var xlPackage = new ExcelPackage(stream)) { // get the first worksheet in the workbook var worksheet = xlPackage.Workbook.Worksheets.FirstOrDefault(); if (worksheet == null) { throw new DptsException("No worksheet found"); } if (userId != null && iRow > 0) { var allColumnsAreEmpty = manager.GetProperties .Select(property => worksheet.Cells[iRow, property.PropertyOrderPosition]) .All(cell => cell == null || cell.Value == null || String.IsNullOrEmpty(cell.Value.ToString())); if (allColumnsAreEmpty) { throw new DptsException("column are empty"); } manager.ReadFromXlsx(worksheet, iRow); var doctor = new Doctor { DoctorId = userId, Gender = manager.GetProperty("Gender").StringValue, ShortProfile = manager.GetProperty("ShortProfile").StringValue, Language = manager.GetProperty("Qualifications").StringValue, RegistrationNumber = manager.GetProperty("RegistrationNumber").StringValue, DateOfBirth = manager.GetProperty("DateOfBirth").StringValue }; _doctorService.AddDoctor(doctor); } } }
public IHttpActionResult AddDoctor([FromBody] DoctorDTO doctorDTO) { if (doctorDTO == null) { return(BadRequest()); } var results = _doctorService.AddDoctor(doctorDTO); return(Ok(results)); }
[HttpPost] ///GUARDAR DOCTOR public ActionResult Save(Doctor doctor) { DoctorValidation.Validate(doctor, ModelState); if (!DoctorValidation.IsValid()) { return(View("Save", doctor)); } DoctorService.AddDoctor(doctor); return(RedirectToAction("List")); }
public IActionResult AddDoctor(DoctorRequest request) { var success = _service.AddDoctor(request); if (success) { return(Ok("added the doctor")); } else { return(BadRequest("an error occured")); } }
public IActionResult AddDoctor(AddDoctorRequest request) { Doctor newDoctor = new Doctor(); newDoctor.FirstName = "Jakub"; newDoctor.LastName = "Michalski"; newDoctor.Email = "*****@*****.**"; request.doctor = newDoctor; var response = _serviceDoctor.AddDoctor(request); return(Ok(response.message)); }
public async Task <IActionResult> Post([FromBody] Doctor doc) { try { return(Ok(await _doctorService.AddDoctor(doc))); } catch (CouchDbException e) { return(BadRequest()); } catch (Exception e) { return(BadRequest()); } }
public IActionResult AddDoctor(AddDoctorRequest request) { try { _doctorService.AddDoctor(request); return(Ok()); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public ActionResult AddDoctor(DoctorViewModel doctor) { try { DoctorDTO doctorDTO = new DoctorDTO { Name = doctor.Name, Surname = doctor.Surname, Patronymic = doctor.Patronymic, SpecialityId = doctor.SpecialityId, TheBeginingOfReception = doctor.TheBeginingOfReception, TheEndOfReception = doctor.TheEndOfReception, Cabinet = doctor.Cabinet, Email = doctor.Email, Login = doctor.Login, Password = doctor.Password }; UserDTO userDTO = new UserDTO { Email = doctor.Email, Login = doctor.Login, Password = doctor.Password }; doctorService.ValidateDoctor(doctorDTO); userService.ValidateUser(userDTO); doctorService.AddDoctor(doctorDTO); RoleDTO roleDTO = roleService.GetRole("Врач"); userDTO.RoleId = roleDTO.Id; userService.AddUser(userDTO); return(RedirectToRoute(new { Controller = "Admin", Action = "Doctors" })); } catch (ValidationException ex) { if (ex.Message.Contains("|")) { string[] Messages = ex.Message.Split('|'); string[] Properties = ex.Property.Split('|'); for (int i = 0; i < Messages.Length; i++) { ModelState.AddModelError(Properties[i], Messages[i]); } } else { ModelState.AddModelError(ex.Property, ex.Message); } } ViewBag.Time = new SelectList(time); ViewBag.Time2 = new SelectList(time, "22:00"); var mapper = new MapperConfiguration(cfg => cfg.CreateMap <SpecialityDTO, SpecialityViewModel>()).CreateMapper(); IEnumerable <SpecialityViewModel> specialities = mapper.Map <IEnumerable <SpecialityDTO>, IEnumerable <SpecialityViewModel> >(specialityService.GetSpecialities()); ViewBag.Specialities = new SelectList(specialities, "Id", "Name"); return(View(doctor)); }
public IActionResult AddDoctor([FromBody] Doctor doc) { doc.ts = new List <DoctorTimeSlots>(); doc.doctorSlots = new List <DoctorTimeSlots>(); try { service.AddDoctor(doc); return(Ok("Added Doctor Successfully")); } catch (DoctorAlreadyExistsException dExe) { return(BadRequest(dExe.Message)); } catch (Exception exe) { return(BadRequest(exe.Message)); } }
public async Task <IActionResult> AddDoctor([FromBody] AddDoctorDto doctorDto) { int doctorId = _doctorService.AddDoctor(doctorDto); var user = new User { UserName = doctorDto.Email, Email = doctorDto.Email, FirstName = doctorDto.FirstName, LastName = doctorDto.LastName, FacilityId = doctorDto.FacilityId, DoctorId = doctorId, Role = Role.FacilityDoctor }; var result = await _userManager.CreateAsync(user, doctorDto.Password); return(Json(JsonResultData.Success())); }
public ActionResult RegisterDoctor(RegisterDoctorVM model) { if (ModelState.IsValid) { UserDTO user = userService.GetUsers().FirstOrDefault(u => u.Login == model.Login && u.Password == model.Password); if (user == null) { model.RoleId = 1; userService.AddUser(MapperUtilVM.MapToUserDTO(model)); // проверяем если пользователь удачно добавлен в бд var newUser = userService.GetUsers().FirstOrDefault(u => u.Login == model.Login && u.Password == model.Password); if (newUser != null) { try { model.UserId = newUser.UserId; doctorService.AddDoctor(MapperUtilVM.MapToDoctorDTO(model)); Session["Login"] = newUser.Login; Session["Id"] = newUser.UserId; Session["Role"] = "Doctor"; Session["DoctorId"] = doctorService.GetDoctors().FirstOrDefault(id => id.UserId == newUser.UserId).DoctorId; FormsAuthentication.SetAuthCookie(model.Login, true); return(RedirectToAction("ListDoctors", "Home")); } catch (Exception ex) { ModelState.AddModelError("", "Ошибка регистрации врача: " + ex.Message); } } } else { ModelState.AddModelError("", "Пользователь с таким логином уже существует"); } } return(View(model)); }
/// <summary> /// Import doctors from XLSX file /// </summary> /// <param name="stream">Stream</param> /// <param name="userId"></param> /// <param name="iRow"></param> public virtual void ImportDoctorsFromXlsx(Stream stream, string userId, int iRow) { //property array var properties = new[] { new PropertyByName <Doctor>("FirstName"), new PropertyByName <Doctor>("LastName"), new PropertyByName <Doctor>("Email"), new PropertyByName <Doctor>("PhoneNumber"), new PropertyByName <Doctor>("Gender"), new PropertyByName <Doctor>("Speciality"), new PropertyByName <Doctor>("ShortProfile"), new PropertyByName <Doctor>("RegistrationNumber"), new PropertyByName <Doctor>("DateOfBirth"), new PropertyByName <Doctor>("Address1"), new PropertyByName <Doctor>("Address2"), new PropertyByName <Doctor>("Hospital"), new PropertyByName <Doctor>("Pincode"), new PropertyByName <Doctor>("City"), new PropertyByName <Doctor>("State"), new PropertyByName <Doctor>("Country"), new PropertyByName <Doctor>("FaxNumber"), new PropertyByName <Doctor>("Website"), new PropertyByName <Doctor>("ConsultationFee"), new PropertyByName <Doctor>("IsAvailability") }; var manager = new PropertyManager <Doctor>(properties); //var tt = manager.GetProperty("FaxNumber").StringValue.Trim(); //var tt1 = manager.GetProperty("Hospital").StringValue.Trim(); //var tt2 = manager.GetProperty("PhoneNumber").StringValue.Trim(); //var tt3 = manager.GetProperty("Website").StringValue.Trim(); using (var xlPackage = new ExcelPackage(stream)) { // get the first worksheet in the workbook var worksheet = xlPackage.Workbook.Worksheets.FirstOrDefault(); if (worksheet == null) { throw new DptsException("No worksheet found"); } if (userId != null && iRow > 0) { var allColumnsAreEmpty = manager.GetProperties .Select(property => worksheet.Cells[iRow, property.PropertyOrderPosition]) .All(cell => cell == null || cell.Value == null || String.IsNullOrEmpty(cell.Value.ToString())); if (allColumnsAreEmpty) { throw new DptsException("column are empty"); } manager.ReadFromXlsx(worksheet, iRow); string sds = manager.GetProperty("IsAvailability").StringValue; string dsdsd = manager.GetProperty("ConsultationFee").StringValue; bool rre = bool.Parse(manager.GetProperty("IsAvailability").StringValue); decimal ds = decimal.Parse(manager.GetProperty("ConsultationFee").StringValue); #region DoctorInfo var doctor = new Doctor { DoctorId = userId, Gender = manager.GetProperty("Gender").StringValue, ShortProfile = manager.GetProperty("ShortProfile").StringValue, // Language = manager.GetProperty("Qualifications").StringValue, RegistrationNumber = manager.GetProperty("RegistrationNumber").StringValue, DateOfBirth = manager.GetProperty("DateOfBirth").StringValue, IsAvailability = bool.Parse(manager.GetProperty("IsAvailability").StringValue), ConsultationFee = decimal.Parse(manager.GetProperty("ConsultationFee").StringValue) }; _doctorService.AddDoctor(doctor); #endregion #region Specialities if (!string.IsNullOrWhiteSpace(manager.GetProperty("Speciality").StringValue) && !string.IsNullOrWhiteSpace(doctor.DoctorId)) { var specilities = manager.GetProperty("Speciality").StringValue.Trim(); foreach (var item in specilities.Split(',').ToList()) { var spec = _specialityService.GetAllSpeciality(false).Where(s => s.Title.Contains(item)).FirstOrDefault(); if (spec != null) { var sp = new SpecialityMapping { Speciality_Id = spec.Id, Doctor_Id = doctor.DoctorId, DateCreated = DateTime.UtcNow, DateUpdated = DateTime.UtcNow }; if (!_specialityService.IsDoctorSpecialityExists(sp)) { _specialityService.AddSpecialityByDoctor(sp); } } } //foreach (var specilityMap in specilities.Split(',').ToList().Select(item => new SpecialityMapping //{ // Speciality_Id = // Doctor_Id = doctor.DoctorId, // DateCreated = DateTime.UtcNow, // DateUpdated = DateTime.UtcNow //}).Where(specilityMap => !_specialityService.IsDoctorSpecialityExists(specilityMap))) //{ // _specialityService.AddSpecialityByDoctor(specilityMap); //} } #endregion #region Address if (!string.IsNullOrWhiteSpace(doctor.DoctorId) && !string.IsNullOrWhiteSpace(manager.GetProperty("Pincode").StringValue) && !string.IsNullOrWhiteSpace(manager.GetProperty("Address1").StringValue) && !string.IsNullOrWhiteSpace(manager.GetProperty("City").StringValue) && !string.IsNullOrWhiteSpace(manager.GetProperty("State").StringValue) && !string.IsNullOrWhiteSpace(manager.GetProperty("Country").StringValue)) { int countryId = 0; int stateId = 0; string rr1 = manager.GetProperty("Country").StringValue.Trim(); string rr2 = manager.GetProperty("Address1").StringValue.Trim(); string rr3 = manager.GetProperty("City").StringValue.Trim(); var country = _countryService.GetAllCountries().Where(c => c.Name.Contains(manager.GetProperty("Country").StringValue.Trim())).FirstOrDefault(); countryId = (country == null) ? 0 : country.Id; string rr = manager.GetProperty("State").StringValue.Trim(); var states = _stateProvinceService.GetAllStateProvince().Where(c => c.Name.Contains(rr)).FirstOrDefault(); stateId = (states == null) ? 0 : states.Id; var address = new Address { StateProvinceId = stateId, //_, CountryId = countryId, Address1 = manager.GetProperty("Address1").StringValue.Trim(), Address2 = manager.GetProperty("Address2").StringValue.Trim(), Hospital = manager.GetProperty("Hospital").StringValue.Trim(), FaxNumber = manager.GetProperty("FaxNumber").StringValue.Trim(), PhoneNumber = manager.GetProperty("PhoneNumber").StringValue.Trim(), Website = manager.GetProperty("Website").StringValue.Trim(), ZipPostalCode = manager.GetProperty("Pincode").StringValue.Trim(), City = manager.GetProperty("City").StringValue.Trim() }; string docAddress = address.Address1 + ", " + address.City + ", " + states.Name + ", " + address.ZipPostalCode; var geoCoodrinate = GetGeoCoordinate(docAddress); if (geoCoodrinate.Count == 2) { address.Latitude = geoCoodrinate[Constants.Lat]; address.Longitude = geoCoodrinate[Constants.Lng]; } else { var geoCoodrinates = GetGeoCoordinate(address.ZipPostalCode); if (geoCoodrinates.Count == 2) { address.Latitude = geoCoodrinates[Constants.Lat]; address.Longitude = geoCoodrinates[Constants.Lng]; } } _addressService.AddAddress(address); if (doctor != null) { var addrMap = new AddressMapping { AddressId = address.Id, UserId = doctor.DoctorId }; _addressService.AddAddressMapping(addrMap); } } #endregion } } }
public async Task <Doctor> AddDoctor(Doctor doctor) { return(await doctorService.AddDoctor(doctor)); }