public JsonResult Delete(int id) { var request = new DoctorRequest { Data = new DoctorModel { Id = id, Account = Account }, Action = ClinicEnums.Action.DELETE.ToString() }; DoctorResponse _response = new DoctorValidator(_unitOfWork).Validate(request); return(Json(new { Status = _response.Status, Message = _response.Message }, JsonRequestBehavior.AllowGet)); }
public IActionResult DeleteDoctor(DoctorRequest doctorRequest) { if (_context.Doctor.Any(e => e.IdDoctor == doctorRequest.IdDoctor)) { var doctor = _context.Doctor.First(d => d.IdDoctor == doctorRequest.IdDoctor); _context.Doctor.Remove(doctor); _context.SaveChanges(); return(Ok("Doctor removed")); } else { return(BadRequest("Bad doctor")); } }
public IActionResult Insert(DoctorRequest request) { var db = new CodeFirstContext(); var doctor = new Doctor() { IdDoctor = request.IdDoctor, FirstName = request.FirstName, LastName = request.LastName, Email = request.Email }; db.Doctor.Add(doctor); db.SaveChanges(); return(StatusCode(201, doctor)); }
public ActionResult Edit(DoctorModel model) { model.Account = Account; var request = new DoctorRequest { Data = model }; DoctorResponse _response = new DoctorValidator(_unitOfWork).Validate(request); ViewBag.Response = $"{_response.Status};{_response.Message}"; ViewBag.DoctorTypes = BindDropDownDoctorType(); return(View()); }
public IActionResult UpdateDoctor(DoctorRequest doctorRequest) { if (_context.Doctor.Any(e => e.IdDoctor == doctorRequest.IdDoctor)) { var d = _context.Doctor.Find(doctorRequest.IdDoctor); d.FirstName = doctorRequest.FirstName; d.LastName = doctorRequest.LastName; d.Email = doctorRequest.Email; _context.SaveChanges(); return(Ok("Doctor " + doctorRequest.Email + " updated!")); } else { return(BadRequest("No doctor found")); } }
public async Task <ActionResult> Create([FromBody] DoctorRequest model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(await _doctorService.Create(model))); } catch (Exception) { return(BadRequest()); } }
public IActionResult UpdateDoctor(DoctorRequest request) { var db = new DoctorDbContext(); var d1 = new Doctor { IdDoctor = request.IdDoctor, FirstName = request.FirstName, LastName = request.LastName, Email = request.Email }; db.Attach(d1); db.SaveChanges(); return(Ok(d1)); }
public bool ModifyDoctor(DoctorRequest request) { var updatedRequest = UpdateDoctor(request); try { _context.Update(updatedRequest); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } return(true); }
public IActionResult Update(DoctorRequest request) { var db = new CodeFirstContext(); var doctor = new Doctor() { IdDoctor = request.IdDoctor, FirstName = request.FirstName, LastName = request.LastName, Email = request.Email }; //db.Doctor.Find(request.IdDoctor); db.Doctor.Update(doctor); db.SaveChanges(); return(StatusCode(201, "Dane zaktualizowane")); }
public bool ModifyDoctor(DoctorRequest doc) { var res = (from d in _context.Doctor where d.IdDoctor == doc.IdDoctor select d).FirstOrDefault(); if (res == null) { return(false); } res.FirstName = doc.FirstName; res.Email = doc.Email; res.LastName = doc.LastName; _context.SaveChanges(); return(true); }
public ActionResult Edit() { if (Request.QueryString["id"] != null) { var request = new DoctorRequest(Request.QueryString["id"].ToString()); DoctorResponse response = new DoctorHandler(_unitOfWork).GetDetail(request); DoctorModel model = response.Entity; ViewBag.Response = response; ViewBag.DoctorTypes = BindDropDownDoctorType(); return(View(model)); } else { return(BadRequestResponse); } }
public string DeleteDoctors(DoctorRequest request) { var delete_doctor = new Doctor { Id = request.IdDoctor }; _context.Remove(delete_doctor); try { _context.Entry(delete_doctor).State = EntityState.Deleted; _context.SaveChanges(); } catch (Exception) { return(null); } return("A doctor has been successfully deleted"); }
public string InsertDoctors(DoctorRequest request) { _context.Doctors.Add(new Doctor { Id = request.IdDoctor, FirstName = request.FirstName, LastName = request.LastName, Email = request.Email }); try { _context.SaveChanges(); } catch (Exception) { return(null); } return("A doctor has been successfully added"); }
public ActionResult Create(DoctorModel model) { model.Account = Account; // set as paramedic model.TypeID = 1; var request = new DoctorRequest { Data = model }; DoctorResponse _response = new DoctorValidator(_unitOfWork, _context).Validate(request); ViewBag.Response = $"{_response.Status};{_response.Message}"; ViewBag.DoctorTypes = BindDropDownDoctorType(); ViewBag.OrganizationList = BindDropDownOrganization(); return(View()); }
public Doctor UpdateDoctor(DoctorRequest request) { var doctor = context.Doctors.FirstOrDefault(d => d.IdDoctor == request.IdDoctor); if (doctor != null) { doctor.FirstName = request.FirstName; doctor.LastName = request.LastName; doctor.Email = request.Email; context.Update(doctor); context.SaveChanges(); return(doctor); } else { return(null); } }
public bool AddDoctor(DoctorRequest request) { var newDoctor = new Doctor { FirstName = request.FirstName, LastName = request.LastName, Email = request.Email }; try { _context.Doctors.Add(newDoctor); _context.SaveChanges(); } catch (Exception) { return(false); } return(true); }
protected void btnSearch_Click(object sender, EventArgs e) { proxy = new WebRef.Service(); // Proxy must accept and hold cookies // proxy.CookieContainer = new System.Net.CookieContainer(); System.Data.DataSet dsDoctors = new DataSet(); DoctorRequest dRequest = new DoctorRequest(); DoctorTransferObject dTransObject = new DoctorTransferObject(); dTransObject.LName = txtSearchValue.Text; dRequest.lastName = dTransObject.LName; // X509Certificate x509 = X509Certificate.(@"c:\certificateSJSU.cer"); proxy.Url = new Uri(proxy.Url).AbsoluteUri; // proxy.ClientCertificates.Add(x509); DoctorResponse dResponse = proxy.GetDoctors(dRequest); // Get instructors that match last name dsDoctors = dResponse.ds; // If there are no results inform user if (dsDoctors.Tables[0].Rows.Count < 1) { lblMessage.ForeColor = Color.Black; lblMessage.BackColor = Color.Red; lblMessage.Text = "No doctor's match the given Last Name"; } else { // Populate list box with results for (int x = 0; x < dsDoctors.Tables[0].Rows.Count; ++x) { this.lstInstructors.Items.Add(new ListItem(dsDoctors.Tables[0].Rows[x][1].ToString() + " " + dsDoctors.Tables[0].Rows[x][2].ToString(), dsDoctors.Tables[0].Rows[x][0].ToString())); } lstInstructors.Visible = true; // btnGo.Visible = true; } }
public DoctorResponse GetDoctors(DoctorRequest request) { DoctorResponse response = new DoctorResponse(); // Set correlation Id response.CorrelationId = request.RequestId; try { // Get customer list via Customer Facade. DoctorFacade facade = new DoctorFacade(); response.ds = facade.GetDoctor(request.lastName); //response.Doctors = new DoctorTransferObject[ListDoc.Count]; //Console.WriteLine(ListDoc.Count.ToString()); // // Package customer data in Customer Transfer Object // int index = 0; // foreach (Doctor doctor in ListDoc) // { //DoctorResponse response = new DoctorResponse(); // transfer.docID = doctor.DoctorID; // transfer.fName = doctor.fName; // transfer.LName = doctor.LName; // transfer.phone = doctor.Phone; // response.Doctors[index++] = transfer; //} } catch (Exception ex) { response.Acknowledge = AcknowledgeType.Failure; response.Message = "Request cannot be handled at this time."+ex.Message; } return response; }
public string UpdateDoctors(DoctorRequest request) { var update_doctor = new Doctor { Id = request.IdDoctor, FirstName = request.FirstName, LastName = request.LastName, Email = request.Email }; _context.Update(update_doctor); try { _context.Entry(update_doctor).State = EntityState.Modified; _context.SaveChanges(); } catch (Exception) { return(null); } return("A doctor has been successfully updated"); }
public IActionResult AddDoctor(DoctorRequest doctorRequest) { if (_context.Doctor.Any(e => e.IdDoctor == doctorRequest.IdDoctor)) { return(BadRequest("Doctor already exists.")); } else { var doctor = new Doctor() { IdDoctor = doctorRequest.IdDoctor, Email = doctorRequest.Email, FirstName = doctorRequest.FirstName, LastName = doctorRequest.LastName, prescriptions = new List <Prescription>() }; _context.Add(doctor); _context.SaveChanges(); return(Ok("Doctor " + doctor.Email + " added!")); } }
public async Task <ActionResult> Update([FromRoute] int id, [FromBody] DoctorRequest request) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id > 0) { return(Ok(await _doctorService.Update(id, request))); } else { return(BadRequest()); } } catch (Exception) { return(BadRequest()); } }
public async Task <Response> Update(int id, DoctorRequest request) { Doctor info = await _doctorRepository.FindById(id); if (info == null) { return(new Response { IsSuccess = false, Message = Messages.NotFound.ToString() }); } info.CC = request.CC; info.Code = request.Code; info.Name = request.Name; info.LastName = request.LastName; int result = await _doctorRepository.Update(info, request.IPSId); if (result > 0) { return(new Response { IsSuccess = true, Message = Messages.Updated.ToString(), Result = result }); } else { return(new Response { IsSuccess = false, Message = Messages.NotUpdated.ToString() }); } }
private void doctorRequestList_SelectedIndexChanged_1(object sender, EventArgs e) { DoctorRequest selected = (DoctorRequest)doctorRequestList.SelectedItem; string type = selected.requestString.Split(',')[0]; if (type == "Plasma") { List <Plasma> comp = controller.getAvailableBloodForRequest <Plasma>(selected); if (comp.Count == 0) { CallDonorsForm callForm = new CallDonorsForm(controller.getAvailableDonorsForRequest(selected), selected); callForm.ShowDialog(); } fillPotentialBloodList(comp); } if (type == "Red") { List <RedBloodCell> comp = controller.getAvailableBloodForRequest <RedBloodCell>(selected); if (comp.Count == 0) { CallDonorsForm callForm = new CallDonorsForm(controller.getAvailableDonorsForRequest(selected), selected); callForm.ShowDialog(); } fillPotentialBloodList(comp); } if (type == "Tromb") { List <Trombocyte> comp = controller.getAvailableBloodForRequest <Trombocyte>(selected); if (comp.Count == 0) { CallDonorsForm callForm = new CallDonorsForm(controller.getAvailableDonorsForRequest(selected), selected); callForm.ShowDialog(); } fillPotentialBloodList(comp); } }
public IActionResult UpdateDoctor(DoctorRequest request) { return(Ok(service.UpdateDoctor(request))); }
public IActionResult AddDoctor(DoctorRequest doctor) { return(Ok(service.AddDoctor(doctor))); }
public IActionResult AddDoctor(DoctorRequest doctorRequest) { _context.AddDoctor(doctorRequest); return(Ok()); }
public IActionResult ModifyDoctor(DoctorRequest doctorRequest) { _context.ModifyDoctor(doctorRequest); return(Ok()); }
public IList <Donor> getAvailableDonorsForRequest(DoctorRequest request) { string[] splitRequest = request.requestString.Split(','); string bloodType = "AB"; bool rh = false; #region Plasma if (splitRequest[0].Equals("Plasma")) { if (splitRequest[1] == "A") { bloodType = "B"; } if (splitRequest[1] == "B") { bloodType = "A"; } if (splitRequest[1] == "AB") { bloodType = "0"; } if (splitRequest[1] == "0") { bloodType = "A"; } return(getNearestDonors(getDonatedDonors() .Where(x => x.bloodType == bloodType) .Where(x => DateTime.Compare(x.getLastDonation().AddMonths(2), DateTime.Now) < 0) .ToList())); } #endregion #region Red if (splitRequest[0].Equals("Red")) { if (splitRequest[1] == "A") { bloodType = "B"; } if (splitRequest[1] == "B") { bloodType = "A"; } if (splitRequest[1] == "AB") { bloodType = "0"; } if (splitRequest[1] == "0") { bloodType = "A"; } rh = bool.Parse(splitRequest[2]); return(getNearestDonors(getDonatedDonors() .Where(x => x.bloodType == bloodType && x.rh == rh) .Where(x => DateTime.Compare(x.getLastDonation().AddMonths(2), DateTime.Now) < 0) .ToList())); } #endregion #region Tromb if (splitRequest[0] == "Tromb") { return(getNearestDonors(getDonatedDonors() .Where(x => DateTime.Compare(x.getLastDonation().AddMonths(2), DateTime.Now) < 0) .ToList())); } #endregion return(null); }
/** * @param val * @return */ public void makeRequest(Location val, int priority, string patientName, string patientCNP, string requestString) { bool foundRequest = false; string donationCenterLocation = val.latitude.ToString() + ',' + val.longitude.ToString(); DoctorRequest req = new DoctorRequest { donationCenter_id = donationCenterLocation, priority = priority, doctor_name = doctor.name, patientCnp = patientCNP, requestString = requestString, doctor_id = doctor.id, hospital = doctor.hospital }; List <string> requestSplitted = requestString.Split(',').ToList <string>(); switch (requestSplitted[0]) { case "Red": { foreach (var dbRequest in this.service.GetAllFromDatabase <DoctorRequest>()) { if (dbRequest.donationCenter_id == donationCenterLocation && dbRequest.isBeeingDelivered == false) { List <string> dbRequestSplitted = dbRequest.requestString.Split(',').ToList <string>(); if (dbRequestSplitted[0] == requestSplitted[0] && dbRequestSplitted[1] == requestSplitted[1] && dbRequestSplitted[2] == requestSplitted[2]) { string newRequestString = dbRequestSplitted[0] + ',' + dbRequestSplitted[1] + ',' + dbRequestSplitted[2] + ','; double amount = Convert.ToDouble(dbRequestSplitted[3]); amount += Convert.ToDouble(requestSplitted[3]); newRequestString += amount.ToString(); dbRequest.requestString = newRequestString; foundRequest = true; this.service.UpdateOneFromDatabase(dbRequest); } } } break; } case "Plasma": { foreach (var dbRequest in this.service.GetAllFromDatabase <DoctorRequest>()) { if (dbRequest.donationCenter_id == donationCenterLocation && dbRequest.isBeeingDelivered == false) { List <string> dbRequestSplitted = dbRequest.requestString.Split(',').ToList <string>(); if (dbRequestSplitted[0] == requestSplitted[0] && dbRequestSplitted[1] == requestSplitted[1]) { string newRequestString = dbRequestSplitted[0] + ',' + dbRequestSplitted[1] + ','; double amount = Convert.ToDouble(dbRequestSplitted[2]); amount += Convert.ToDouble(requestSplitted[2]); newRequestString += amount.ToString(); dbRequest.requestString = newRequestString; foundRequest = true; this.service.UpdateOneFromDatabase(dbRequest); } } } break; } case "Tromb": { foreach (var dbRequest in this.service.GetAllFromDatabase <DoctorRequest>()) { if (dbRequest.donationCenter_id == donationCenterLocation && dbRequest.isBeeingDelivered == false) { List <string> dbRequestSplitted = dbRequest.requestString.Split(',').ToList <string>(); if (dbRequestSplitted[0] == requestSplitted[0]) { string newRequestString = dbRequestSplitted[0] + ','; double amount = Convert.ToDouble(dbRequestSplitted[1]); amount += Convert.ToDouble(requestSplitted[1]); newRequestString += amount.ToString(); dbRequest.requestString = newRequestString; foundRequest = true; this.service.UpdateOneFromDatabase(dbRequest); } } } break; } default: break; } if (foundRequest == false) { this.service.AddToDatabase(req); } }
public IActionResult AddDoctor(DoctorRequest request) { Doctor doc = _context.addDoctor(request); return(Created("Utworzono doktora", doc)); }
public async Task <Response <Doctor> > InsertItem(DoctorRequest doctorRequest) { using var transaction = _db.Database.BeginTransaction(); try { User user = new User(); user.UserType = doctorRequest.UserType; user.FirstName = doctorRequest.FirstName; user.LastName = doctorRequest.LastName; user.FatherHusbandName = doctorRequest.FatherHusbandName; user.Gender = doctorRequest.Gender; user.Cnic = doctorRequest.Cnic; user.Contact = doctorRequest.Contact; user.EmergencyContact = doctorRequest.EmergencyContact; user.Email = doctorRequest.Email; user.Address = doctorRequest.Address; user.JoiningDate = doctorRequest.JoiningDate; user.FloorNo = doctorRequest.FloorNo; user.Experience = doctorRequest.Experience; user.DateOfBirth = doctorRequest.DateOfBirth; user.MaritalStatus = doctorRequest.MaritalStatus; user.Religion = doctorRequest.Religion; await _db.Users.AddAsync(user); await _db.SaveChangesAsync(); if (doctorRequest.QualificationList != null) { if (doctorRequest.QualificationList.Count > 0) { foreach (QualificationRequest drQualification in doctorRequest.QualificationList) { Qualification qualification = new Qualification(); qualification.UserId = user.Id; qualification.Certificate = drQualification.Certificate; qualification.Description = drQualification.Description; qualification.QualificationType = drQualification.QualificationType; await _db.Qualifications.AddAsync(qualification); await _db.SaveChangesAsync(); } } } Doctor doctor = new Doctor(); doctor.UserId = user.Id; doctor.ConsultationFee = doctorRequest.ConsultationFee; doctor.EmergencyConsultationFee = doctorRequest.EmergencyConsultationFee; doctor.ShareInFee = doctorRequest.ShareInFee; doctor.SpecialityType = doctorRequest.SpecialityType; await _db.Doctors.AddAsync(doctor); await _db.SaveChangesAsync(); transaction.Commit(); return(new Response <Doctor>(true, "Success: Inserted data.", doctor)); } catch (Exception exception) { transaction.Rollback(); return(new Response <Doctor>(false, $"Server Failure: Unable to insert data. Because {exception.Message}", null)); } }
public async Task <Response <Doctor> > UpdateItem(int id, DoctorRequest doctorRequest) { using var transaction = _db.Database.BeginTransaction(); try { if (id != doctorRequest.Id) { transaction.Rollback(); return(new Response <Doctor>(false, "Failure: Id sent in body does not match object Id", null)); } Doctor doctor = await _db.Doctors.Include(x => x.User.Qualifications).FirstOrDefaultAsync(x => x.Id == id); if (doctor == null) { transaction.Rollback(); return(new Response <Doctor>(false, $"Failure: Unable to update doctor {doctorRequest.FirstName}. Because Id is invalid. ", null)); } doctor.ConsultationFee = doctorRequest.ConsultationFee; doctor.EmergencyConsultationFee = doctorRequest.EmergencyConsultationFee; doctor.ShareInFee = doctorRequest.ShareInFee; doctor.SpecialityType = doctorRequest.SpecialityType; await _db.SaveChangesAsync(); if (doctorRequest.QualificationList != null) { if (doctorRequest.QualificationList.Count > 0) { foreach (QualificationRequest drQualification in doctorRequest.QualificationList) { Qualification qualification = await _db.Qualifications.FirstOrDefaultAsync(x => x.Id == drQualification.Id && x.UserId == doctor.UserId); if (qualification == null) { transaction.Rollback(); return(new Response <Doctor>(false, $"Failure: Unable to update qualification {drQualification.Certificate}. Because Id is invalid. ", null)); } qualification.Certificate = drQualification.Certificate; qualification.Description = drQualification.Description; qualification.QualificationType = drQualification.QualificationType; await _db.SaveChangesAsync(); } } } User user = await _db.Users.FirstOrDefaultAsync(x => x.Id == doctor.UserId); if (user == null) { transaction.Rollback(); return(new Response <Doctor>(false, "Failure: Data doesn't exist.", null)); } user.UserType = doctorRequest.UserType; user.FirstName = doctorRequest.FirstName; user.LastName = doctorRequest.LastName; user.FatherHusbandName = doctorRequest.FatherHusbandName; user.Gender = doctorRequest.Gender; user.Cnic = doctorRequest.Cnic; user.Contact = doctorRequest.Contact; user.EmergencyContact = doctorRequest.EmergencyContact; user.Email = doctorRequest.Email; user.Address = doctorRequest.Address; user.JoiningDate = doctorRequest.JoiningDate; user.FloorNo = doctorRequest.FloorNo; user.Experience = doctorRequest.Experience; user.DateOfBirth = doctorRequest.DateOfBirth; user.MaritalStatus = doctorRequest.MaritalStatus; user.Religion = doctorRequest.Religion; await _db.SaveChangesAsync(); transaction.Commit(); return(new Response <Doctor>(true, "Success: Updated data.", doctor)); } catch (Exception exception) { transaction.Rollback(); return(new Response <Doctor>(false, $"Server Failure: Unable to update data. Because {exception.Message}", null)); } }