コード例 #1
0
        public IActionResult MessageCreate(MessageModel model)
        {
            if (ModelState.IsValid)
            {
                UserMessage message = new UserMessage()
                {
                    MessageText = model.MessageText, Id = _unitOfWork.UserRepository.GetUserId(User)
                };
                _unitOfWork.UserMessageRepository.Add(message);

                foreach (var phone in model.PhoneNumber)
                {
                    PhoneRec currentPhone;
                    currentPhone = _unitOfWork.PhoneRecRepository.SearchByPhone(phone);

                    if (currentPhone == null)
                    {
                        currentPhone = new PhoneRec()
                        {
                            PhoneNumber = phone, UserId = _unitOfWork.UserRepository.GetUserId(User)
                        };
                        _unitOfWork.PhoneRecRepository.Add(currentPhone);
                    }

                    _unitOfWork.MessageRepository.Create(message.UserMesId, currentPhone.PhoneId);
                }

                _unitOfWork.Save();
                return(View("MessageList"));
            }
            else
            {
                return(View(model));
            }
        }
コード例 #2
0
        public PhoneVieweModel Get(string userId)
        {
            PhoneRec phone = _unitOfWork.PhoneRecRepository.GetByID(userId);

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

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