public void Patch(MobileNumber mobileNum) { MobileNumber dbMobileNum = _mobileNumberRepo.findOneBy(MobileNumber => MobileNumber.id.Equals(mobileNum.id)); dbMobileNum.number = mobileNum.number; _mobileNumberRepo.Save(); }
private ICollection <MobileNumber> createMobileNumbers(List <string> mobileNumbers) { ICollection <MobileNumber> mobileNumberEntities = new List <MobileNumber>(); foreach (string mobNum in mobileNumbers) { var dbMobileNum = _mobileNumberRepo.findOneBy(MobileNumber => MobileNumber.number.Equals(mobNum)); if (dbMobileNum != null && dbMobileNum.contact != null) { throw new Exception("Mobile number " + dbMobileNum.number + " is already in use"); } if (dbMobileNum == null) { MobileNumber newMobileNum = new MobileNumber(); newMobileNum.number = mobNum; _mobileNumberRepo.Create(newMobileNum); _mobileNumberRepo.Save(); mobileNumberEntities.Add(newMobileNum); continue; } mobileNumberEntities.Add(dbMobileNum); } return(mobileNumberEntities); }