public async Task AppointmentService_Delete_Appointment_Test() { //Arrange Guid appGuid = _appointmentOne; _appointmentMockRepo.Setup(x => x.DeleteAppointment(appGuid)).Callback((Guid guid) => { _appointments.Where(a => a.AppointmentGuid == guid).FirstOrDefault().BookingCancelled = true; }).ReturnsAsync(true); //Act var res = await _appService.DeleteAppointment(appGuid); //Assert Assert.IsTrue(res.ReturnObject); Assert.IsTrue(_appointments.Where(a => a.AppointmentGuid == appGuid).FirstOrDefault().BookingCancelled); }
public async Task DeleteAppointment() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Delete_Appointment") .Options; var appointment = new Appointment { Id = 1, }; int count; using (var db = new ApplicationDbContext(options)) { db.Appointments.Add(appointment); db.SaveChanges(); AppointmentService service = new AppointmentService(db); await service.DeleteAppointment(appointment.Id); count = db.Appointments.Count(); } Assert.Equal(0, count); }
public async Task <IHttpActionResult> DeleteAppointment(AppointmentModel appointment) { if (appointment == null) { return(BadRequest("Please provide valid inputs!")); } //CommonResponse validatedResponse = await AuthService.ValidateUserAndToken(); //if (!validatedResponse.IsError) //{ if (await AppointmentService.AppointmentExists(appointment)) { if (await AppointmentService.DeleteAppointment(appointment)) { return(Ok("Appointment Deleted Successfully!")); } else { return(BadRequest("Failed to Delete Appointment!")); } } else { return(BadRequest("No Such Appointment Exisits!")); } //} //else //{ // return Unauthorized(); //} }
protected void ApointmentGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteAppointment") { int rowNumber = Convert.ToInt32(e.CommandArgument); int ApointmentId = Convert.ToInt32(ApointmentGrid.Rows[rowNumber].Cells[0].Text); AppointmentService appser = new AppointmentService(); appser.DeleteAppointment(ApointmentId); } }
protected void ShowAppointment_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteAppointment") { int rowNumber = Convert.ToInt32(e.CommandArgument); int appId = Convert.ToInt32(ShowAppointment.Rows[rowNumber].Cells[0].Text); AppointmentService ap = new AppointmentService(); ap.DeleteAppointment(appId); SortDDL_SelectedIndexChanged(sender, e); } }
public void Delete() { var dep = DependencyService.Get <Common.ServiceContracts.IAppointment>(); using (AppointmentService service = new AppointmentService(dep)) { bool b = service.DeleteAppointment(appoint.AppointmentId); if (!b) { Message = "Failed to delete Appointment"; } } }
protected void ShowAppointment_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteAppointment") { int rowNumber = Convert.ToInt32(e.CommandArgument); int appId = Convert.ToInt32(ShowAppointment.Rows[rowNumber].Cells[0].Text); DateTime appDate = Convert.ToDateTime(ShowAppointment.Rows[rowNumber].Cells[3].Text); if (DateTime.Now.AddDays(1) < appDate) { AppointmentService appser = new AppointmentService(); appser.DeleteAppointment(appId); SortAppointmentDDL_SelectedIndexChanged(sender, e); } else { Response.Write("<script>alert('לא ניתן לבטל את התור מכיוון שהתור עוד פחות מיום')</script>"); } } }
private void CancelScheduledActionButton_Click(object sender, RoutedEventArgs e) { RoomSchedulesDTO selectedScheduledAction = (RoomSchedulesDTO)RoomScheduledActionsDataGrid.SelectedItem; if (selectedScheduledAction.ScheduleType == ScheduleType.Appointment) { _appointmentService.DeleteAppointment(selectedScheduledAction.Id); } else if (selectedScheduledAction.ScheduleType == ScheduleType.EquipmentTransfer) { _equipmentService.DeleteEquipmentTransfer(selectedScheduledAction.Id); } else if (selectedScheduledAction.ScheduleType == ScheduleType.Renovation) { _renovationService.DeleteRenovation(selectedScheduledAction.Id); } GetDataAndDisplayItInScheduledActionsDataGrid(); ShowActionSuccessfullyCancelledDialog(); }
public async Task <IActionResult> Delete(int id) { try { var oldClient = await _appointmentService.GetAppointmentByIdAsync(id); if (oldClient == null) { return(NotFound()); } if (await _appointmentService.DeleteAppointment(oldClient)) { return(Ok()); } } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e}")); } return(BadRequest("Failed to delete the appointment")); }
public static void Appointment() { //look for all the appointments in database //check if the date of the appointment has already had, if so, delete the appointment //check if the doctor is not in vacation in this day(i think i already did it but check again) AppointmentService appser = new AppointmentService(); VacationService vc = new VacationService(); MessageService ms = new MessageService(); string s = "SELECT * from Apointment", whereclout = ""; string tabels = "Apointment"; DataSet ds = appser.GetApointmentAndSort(s, tabels, ""); DataSet vacationDs; DateTime timeOfAppointment; DateTime startVacDate, endVacDate; string doctorId, userId, content = ""; int AppointmentId; Message m = new Message(); Doctor d; if (ds.Tables[0].Rows.Count != 0) { //check all the Appointments for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { AppointmentId = Convert.ToInt32(ds.Tables[0].Rows[i]["ApointmentId"].ToString()); timeOfAppointment = Convert.ToDateTime(ds.Tables[0].Rows[i]["ApointmentDate"].ToString()); doctorId = ds.Tables[0].Rows[i]["ApointmentDoctorId"].ToString(); userId = ds.Tables[0].Rows[i]["ApointmentUserId"].ToString(); //if the date has been past, then delete the appointment if (timeOfAppointment < DateTime.Now) { //delete the appointment appser.DeleteAppointment(AppointmentId); break; } //check if the doctor is in vacation in this date d = GetAllDoctorDataById(doctorId); vacationDs = vc.IsDoctorOnVacation(doctorId); if (vacationDs.Tables[0].Rows.Count != 0) { for (int j = 0; j < vacationDs.Tables[0].Rows.Count; j++) { startVacDate = Convert.ToDateTime(vacationDs.Tables[0].Rows[j]["VacationStartDate"].ToString()); endVacDate = Convert.ToDateTime(vacationDs.Tables[0].Rows[j]["VacationEndDate"].ToString()); if (startVacDate <= timeOfAppointment && timeOfAppointment <= endVacDate) { //create a message from manager to user that says the appointment is canceled //because the doctor is on vacation m.CMessageUserId = userId; m.CMessageManagerId = "325132850"; m.CMessageSendDate = DateTime.Now; m.CMessageTheme = "ביטול תור"; content = "התור שהיה אמור להתקיים בתאריך " + timeOfAppointment + " עם הרופא " + d.CDoctorName + " התבטל בעקבות זה שהרופא יצא לחופשה"; m.CMessageContent = content; m.CMessageWhoSent = "manager"; //Inseart the message to the database whereclout = "INSERT INTO Messages(MessageUserId,MessageManagerId,MessageTheme,MessageContent,MessageSendDate,MessageWhoSent)"; whereclout += " VALUES('" + m.CMessageUserId + "','" + m.CMessageManagerId + "','" + m.CMessageTheme + "','" + m.CMessageContent + "',#" + m.CMessageSendDate + "#,'" + m.CMessageWhoSent + "')"; ms.InseartMessageToDatabase(whereclout); } } } } } }
public void DeleteAppointment(Appointment oldAppointment) { _appointmentService.DeleteAppointment(oldAppointment); }
public ActionResult Delete(CustomAppoinmentModel app) { AppointmentService.DeleteAppointment(app); return(Json(true, JsonRequestBehavior.AllowGet)); }
private void CancelExaminationButton_Click(object sender, RoutedEventArgs e) { _appointmentService.DeleteAppointment(ExaminationId); this.Close(); ShowAppointmentSuccessfullyCancelledDialog(); }
public void DeleteAppointment(Appointment appointment) { appointmentService.DeleteAppointment(appointment); }