コード例 #1
0
        public ActionResult Index(int id)
        {
            DialogRepository dialogRepository = new DialogRepository();

            if (id == CurrentAccountID)
            {
                List <InterlocutorModel> interlocutorsList = dialogRepository.GetInterlocutors(CurrentAccountID);
                if (interlocutorsList.Count == 0)
                {
                    return(RedirectToAction("Index", "Friend", CurrentAccountID));
                }
                else
                {
                    _convModel.InterlocutorID = interlocutorsList.First().accountID;
                }
            }
            else
            {
                _convModel.InterlocutorID = id;
            }

            _convModel.CurrentUserID = CurrentAccountID;

            _convModel.InterlocutorUsername = dialogRepository.GetInterlocutorNameByID(_convModel.InterlocutorID);
            _convModel.Dialogs       = dialogRepository.GetMessagesForDialog(_convModel.CurrentUserID, _convModel.InterlocutorID);
            _convModel.Interlocutors = dialogRepository.GetInterlocutors(_convModel.CurrentUserID);

            return(View("Index", _convModel));
        }