public ActionResult Delete(int memberid) { // Clinic object Clinic clinic = _VCRepo.Get(); /*delte appointment first*/ IEnumerable <Appointment> memApp = _AppRepo.GetByMemberId(memberid); if (memApp != null && memApp.Count() > 0) { foreach (var app in memApp) { /*But first, remove appointment from time slot*/ // Check for time slot of each appointment IEnumerable <AppointmentTimeSlot> appTimeblock = _AppTimeRepo.GetByAppointmentID(app.id); if (appTimeblock != null && appTimeblock.Count() > 0) { foreach (var apptime in appTimeblock) { //Update Timeblock (2) TimeSlot updateTimeBlock = _TimeSlotRepo.GetByID(apptime.timeId); // 2.1 reduce number of case updateTimeBlock.numberofCase -= 1; // 2.2 update status if (updateTimeBlock.numberofCase == 0 || updateTimeBlock.numberofCase <= clinic.maximumCase) { updateTimeBlock.status = "Free"; } _TimeSlotRepo.Update(updateTimeBlock); //Delete AppointmentTimeblock (1) ^ _AppTimeRepo.Delete(apptime); } } // Then remove appointment (3) _AppRepo.Delete(app); } } //Then Remove pet (4) IEnumerable <Pet> memPet = _PetRepo.GetByMemberID(memberid); if (memPet != null && memPet.Count() > 0) { foreach (var pet in memPet) { _PetRepo.Delete(pet); } } Member member = _MemberRepo.GetByID(memberid); _MemberRepo.Delete(member); return(Json(new { Result = "Success" })); }
public bool Delete(int id) { var pet = _repository.FindById(id); _repository.Delete(pet); return(_repository.SaveChanges()); }
public void Delete(Guid key) { _petRepository.Delete(new Pet() { Key = key }); }
public Pet Delete(int id) { if (id <= 0) { throw new ArgumentNullException(); } return(_petRepository.Delete(id)); }
public Pet Delete(int id) { Pet pet = _petRepository.ReadById(id); if (pet == null) { throw new NullReferenceException($"The pet with Id: {id} does not exist"); } return(_petRepository.Delete(id)); }
public void DeletePet(int petId, int ownerId) { if (!petRepository.Records.Any(x => x.PetId == petId && x.OwnerId == ownerId)) { throw new CustomDbConflictException("Pet not found."); } var pet = petRepository.Records.Where(x => x.PetId == petId).FirstOrDefault(); petRepository.Delete(pet); }
public IActionResult Delete(int Id) { try{ _petRepository.Delete(_petRepository.GetPet(Id)); _clientNotification.AddSweetNotification("Success", "Pet Deleted", NotificationType.success); return(Ok()); } catch (Exception ex) { _clientNotification.AddSweetNotification("Could not delete pet. Please try again!", "", NotificationType.error); return(BadRequest()); } }
public Pet Delete(int index) { try { return(_prep.Delete(index)); } catch (Exception e) { throw new ServiceException("Error deleting pet: " + e.Message, e); } }
[HttpDelete("{petid}")] // delete pet public ActionResult DeletePet(int petid) { _petRepository.Delete(_petRepository.Get(petid)); if (_petRepository.Save()) { return(Ok("Pet deleted")); } return(Ok(new { errorcode = Errors.ErrorCode.Pet_Not_Found })); }
public IActionResult Delete(int Id) { try { var pet = _petRepository.GetSinglePet(Id); _petRepository.Delete(pet); return(Ok()); } catch (Exception ex) { return(BadRequest()); } }
public Pet Delete(int id) { if (id < 1) { throw new ArgumentException($"Id must be a positive integer."); } Pet pet = _petRepository.Delete(id); if (pet is null) { throw new KeyNotFoundException($"No record with id {id} was found."); } return(pet); }
// DELETE api/<controller>/5 public IHttpActionResult Delete(int id) { try { _repository.Delete(id); if (_repository.Status == StatusRequest.Deleted) { return(Ok()); } return(BadRequest(ErrorsWriter.GetErrors(_repository.ErrorMessage))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <Pet> DeleteAsync(int id) { // Find the Pet to delete... var existingPet = await petRepository.GetAsync(id); if (existingPet == null) { return(null); } try { petRepository.Delete(existingPet); await unitOfWork.CompleteAsync(); return(existingPet); } catch (Exception) { // TODO: Better error handling! return(null); } }
public Pet Delete(int id) { return(findPetById(id) == null ? throw new InvalidDataException("Pet not found or already deleted") : _petRepository.Delete(id)); }
public void Delete(int id) { _petRepository.Delete(id); }
public Pet DeletePet(int id) { return(petRepos.Delete(id)); }
//Sletter pet public PetEntity DeletePet(int idForDeletePet) { return(_petRepo.Delete(idForDeletePet)); }
public async Task <IActionResult> Delete(Guid id) { return(Ok(await _repository.Delete(id))); }
public Pet DeletPet(int id) { return(_petRepo.Delete(id)); }
public Task Delete(Guid id) { return(_petRepository.Delete(id)); }
public bool Delete(int Id) { return(petRepository.Delete(Id)); }
public async Task <bool> DeletePetAsync(long petId) { return(await _petRepository.Delete(petId)); }
public Pet DeletePet(int id) { return(_petRepository.Delete(id)); }
public void Delete(int id) { _i.Delete(id); }
public void DeletePet(int id) { _petRepo.Delete(id); }
public ActionResult Delete(Pet pet) { petRepo.Delete(pet); return(RedirectToAction("Index")); }
public void Delete(Pet pet) { _petRepo.Delete(pet); }
public void Delete(Guid id) { _petRepository.Delete(id); }