Esempio n. 1
0
        /// <summary>
        /// This method sets IsRead value of a message to true
        /// </summary>
        /// <param name="msgID">msgID</param>
        public void SetMessageIsReadTrue(int msgID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userMsgRepo =
                        new InternalUserMessageRepository(new EFRepository <InternalUserMessage>(), unitOfWork);

                    ObjectSet <InternalUserMessage> userMsgObjSet =
                        ((CurrentDeskClientsEntities)userMsgRepo.Repository.UnitOfWork.Context).InternalUserMessages;

                    //Get that particular msg
                    var selectedMsg = userMsgObjSet.Where(msg => msg.PK_MessageID == msgID).FirstOrDefault();

                    if (selectedMsg != null)
                    {
                        selectedMsg.IsRead = true;
                        userMsgRepo.Save();
                    }
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// This method sets method status to archive
        /// </summary>
        /// <param name="pkMsgIDs">pkMsgIDs</param>
        /// <returns></returns>
        public bool ArchiveSelectedMessage(string pkMsgIDs)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userMsgRepo =
                        new InternalUserMessageRepository(new EFRepository <InternalUserMessage>(), unitOfWork);

                    ObjectSet <InternalUserMessage> userMsgObjSet =
                        ((CurrentDeskClientsEntities)userMsgRepo.Repository.UnitOfWork.Context).InternalUserMessages;

                    //Get array of msg IDs
                    var arrMsgIDs = pkMsgIDs.TrimEnd(',').Split(',');

                    foreach (var msg in arrMsgIDs)
                    {
                        int msgID = Convert.ToInt32(msg);

                        //Get selected msg
                        var selectedMsg = userMsgObjSet.Where(msge => msge.PK_MessageID == msgID).FirstOrDefault();

                        //Update status
                        if (selectedMsg != null)
                        {
                            selectedMsg.MessageStatus = "archive";
                        }
                    }

                    userMsgRepo.Save();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(false);
            }
        }