public async Task <IActionResult> EditGetEductionalCenterPhone([FromForm] EductionalCenterPhone eductionalCenterPhone) { EductionalCenterPhone eductionalCenterPhoneById = await _eductionalCenterPhoneRepository.GetEductionalCenterPhoneById(eductionalCenterPhone.EductionalCenterPhoneId); //GetTeacherPhoneById search if (eductionalCenterPhoneById == null) { return(Content("not found , please Check!...")); } else if (eductionalCenterPhone.EductionalCenterPhoneNumber != eductionalCenterPhoneById.EductionalCenterPhoneNumber) { var isExistNumber = _eductionalCenterPhoneRepository.CheckPhoneExists(eductionalCenterPhone.EductionalCenterPhoneNumber); if (isExistNumber.Result != null) { return(Content("this phone number exists as before!!!. Please Write Another Phone")); } else { await _eductionalCenterPhoneRepository.EditEductionalCenterPhone(eductionalCenterPhone); return(Created("EductionalCenterTable", eductionalCenterPhone)); } } else { await _eductionalCenterPhoneRepository.EditEductionalCenterPhone(eductionalCenterPhone); return(Created("EductionalCenterTable", eductionalCenterPhone)); } }
//Edit EductionalCenter Phone public async Task EditEductionalCenterPhone(EductionalCenterPhone newEductionalCenterPhone) { EductionalCenterPhone oldEductionalCenterPhone = await GetEductionalCenterPhoneById(newEductionalCenterPhone.EductionalCenterPhoneId); oldEductionalCenterPhone.EductionalCenterPhoneNumber = newEductionalCenterPhone.EductionalCenterPhoneNumber; _context.Entry(oldEductionalCenterPhone).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public async Task <ActionResult> AddEductionalCenterPhone([FromForm] EductionalCenterPhone eductionalCenterPhone) { // check phone number is there exists in database var isExistNumber = _eductionalCenterPhoneRepository.CheckPhoneExists(eductionalCenterPhone.EductionalCenterPhoneNumber); if (isExistNumber.Result != null) { return(Content("this phone number exists as before!!!. Please Write Another Phone")); } await _eductionalCenterPhoneRepository.AddEductionalCenterPhone(eductionalCenterPhone); return(Created("EductionalCenterTable", eductionalCenterPhone)); }
public async Task <IActionResult> DeleteEductionalCenterPhone(int eductionalCenterPhoneId) { // check phoneteache is exist in table or no EductionalCenterPhone eductionalCenterPhoneById = await _eductionalCenterPhoneRepository.GetEductionalCenterPhoneById(eductionalCenterPhoneId); if (eductionalCenterPhoneById == null) { return(Content("not found , please Check!...")); } else { await _eductionalCenterPhoneRepository.DeleteEductionalCenterPhone(eductionalCenterPhoneById); return(Ok("Deleted Successfully")); } }
// delet EductionalCenterPhone public async Task DeleteEductionalCenterPhone(EductionalCenterPhone eductionalCenterPhone) { _context.EductionalCenterPhones.Remove(eductionalCenterPhone); await _context.SaveChangesAsync(); }
// Add NewPhone to EductionalCenterPhone public async Task AddEductionalCenterPhone(EductionalCenterPhone eductionalCenterPhone) { await _context.EductionalCenterPhones.AddAsync(eductionalCenterPhone); await _context.SaveChangesAsync(); }