Exemplo n.º 1
0
        public async void PushNotifyToAccounts(string orderCode, RequestTypeEnum type)
        {
            try
            {
                var mess = string.Empty;
                IEnumerable <Entities.Account> lstAcc = new List <Entities.Account>();
                switch (type)
                {
                case RequestTypeEnum.CSRequestDestroy:
                {
                    mess   = string.Format("Mã đơn {0} - CSKH báo hủy đơn!", orderCode);
                    lstAcc = _accountBo.GetListByRole(UserTypeEnum.KitchenManager.GetHashCode());
                    break;
                }

                case RequestTypeEnum.KitchenDestroy:
                {
                    mess   = string.Format("Mã đơn {0} - Quản lý bếp đã hủy đơn, cần báo lại khách!", orderCode);
                    lstAcc = _accountBo.GetListByRole(UserTypeEnum.CustomerService.GetHashCode());
                    break;
                }
                }

                foreach (var acc in lstAcc)
                {
                    var key   = KeyCacheHelper.GenCacheKeyStatic(ConstKeyCached.NotifyAccount, acc.UserName);
                    var score = DateTime.Now.Ticks;
                    await cacheClient.SortedSetAddAsync <string>(key, mess, score);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }