public PhoneVieweModel Get(string userId) { PhoneRec phone = _unitOfWork.PhoneRecRepository.GetByID(userId); PhoneVieweModel recepient = new PhoneVieweModel { id = phone.PhoneId, PhoneNumber = phone.PhoneNumber }; return(recepient); }
public IActionResult UpdatePhone(PhoneVieweModel obj) { PhoneRec phone = new PhoneRec(); phone.PhoneId = obj.id; phone.UserId = _unitOfWork.UserRepository.GetUserId(User); phone.PhoneNumber = obj.PhoneNumber; _unitOfWork.PhoneRecRepository.Update(phone); return(new ObjectResult("Employee modified successfully!")); }
public ICollection <PhoneVieweModel> GetPhones() { List <PhoneRec> phones = _unitOfWork.PhoneRecRepository.GetByUserId(_unitOfWork.UserRepository.GetUserId(User)); List <PhoneVieweModel> recepientModels = new List <PhoneVieweModel>(); foreach (var phone in phones) { PhoneVieweModel recepient = new PhoneVieweModel { id = phone.PhoneId, PhoneNumber = phone.PhoneNumber }; recepientModels.Add(recepient); } return(recepientModels); }
public IActionResult CreatePhone(PhoneVieweModel obj) { if ((_unitOfWork.PhoneRecRepository.SearchByPhone(obj.PhoneNumber) == null) || (_unitOfWork.PhoneRecRepository.SearchByPhone(obj.PhoneNumber).UserId != _unitOfWork.UserRepository.GetUserId(User))) { PhoneRec phone = new PhoneRec() { UserId = _unitOfWork.UserRepository.GetUserId(User), PhoneNumber = obj.PhoneNumber }; _unitOfWork.PhoneRecRepository.Add(phone); _unitOfWork.Save(); } else { return(new ObjectResult("Resipient already exists")); } return(View()); }