コード例 #1
0
        public PhoneVieweModel Get(string userId)
        {
            PhoneRec phone = _unitOfWork.PhoneRecRepository.GetByID(userId);

            PhoneVieweModel recepient = new PhoneVieweModel {
                id = phone.PhoneId, PhoneNumber = phone.PhoneNumber
            };

            return(recepient);
        }
コード例 #2
0
        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!"));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 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());
 }