예제 #1
0
        private bool saveMessage(Int32 iUserId, Int32 iPrivateLabelId)
        {
            Int32            iShopId;
            Boolean          bFound     = false;
            Boolean          bHasShop   = checkUserPrefferedShop(iUserId, out iShopId);
            List <MessageBL> lstMessage = MessageBL.getDataByUserIdAndType(iUserId, Constants.REGISTRATIONMESSAGTYPE);

            if (lstMessage != null && lstMessage.Count > 0)
            {
                foreach (MessageBL objMessage in lstMessage)
                {
                    if (objMessage.iShopID == null)
                    {
                        objMessage.bIsRead       = false;
                        objMessage.dtMessageTime = DateTime.Now;
                        objMessage.strMessage    = Constants.REGISTRATIONMESSAGE;
                        if (iPrivateLabelId != 0)
                        {
                            objMessage.iPrivateLabelID = iPrivateLabelId;
                        }
                        bFound = true;
                    }
                    else
                    {
                        objMessage.bIsRead    = (bHasShop && iShopId == objMessage.iShopID) ? true : objMessage.bIsRead;
                        objMessage.strMessage = Constants.PREFFEREDSHOPMESSAGE;
                        bFound = true;
                    }
                    objMessage.Save();
                }
            }
            if (!bFound)
            {
                MessageBL objMessage = new MessageBL();
                objMessage.iPhoneUserID  = iUserId;
                objMessage.iType         = Constants.REGISTRATIONMESSAGTYPE;
                objMessage.strMessage    = Constants.REGISTRATIONMESSAGE;
                objMessage.bIsRead       = false;
                objMessage.dtMessageTime = DateTime.Now;
                if (iPrivateLabelId != 0)
                {
                    objMessage.iPrivateLabelID = iPrivateLabelId;
                }
                objMessage.Save();

                if (bHasShop)
                {
                    MessageBL _objMessage = new MessageBL();
                    _objMessage.iShopID       = iShopId;
                    _objMessage.iPhoneUserID  = iUserId;
                    _objMessage.iType         = Constants.REGISTRATIONMESSAGTYPE;
                    _objMessage.strMessage    = Constants.PREFFEREDSHOPMESSAGE;
                    _objMessage.bIsRead       = true;
                    _objMessage.dtMessageTime = DateTime.Now;
                    _objMessage.Save();
                }
            }
            return(false);
        }
예제 #2
0
        private bool saveMessage(Int32 iUserId)
        {
            Int32   iShopId;
            Boolean hasGroupOfPrivateShops;
            Boolean bPerformOperation;
            Boolean bHasShop = setUserPrefferedShop(iUserId, out iShopId, out hasGroupOfPrivateShops, out bPerformOperation);

            if (hasGroupOfPrivateShops || !(bPerformOperation))
            {
                return(false);
            }
            if (bHasShop)
            {
                DeletedUsersFromRepairProspectBL objDeletedUsersFromRepairProspectBL = DeletedUsersFromRepairProspectBL.getDataByShopId(iShopId, iUserId);
                if (objDeletedUsersFromRepairProspectBL != null)
                {
                    objDeletedUsersFromRepairProspectBL.Delete();
                }
                UnreadUsersFromRepairProspectBL OldPrefferedShop = UnreadUsersFromRepairProspectBL.getDataByUserId(iUserId);
                if (OldPrefferedShop != null)
                {
                    if (OldPrefferedShop.ShopID != iShopId)
                    {
                        OldPrefferedShop.Delete();
                    }
                }
                UnreadUsersFromRepairProspectBL objOldEntry = UnreadUsersFromRepairProspectBL.getDataByShopId(iShopId, iUserId);
                if (objOldEntry == null)
                {
                    UnreadUsersFromRepairProspectBL objUnreadUsersFromRepairProspectBL = new UnreadUsersFromRepairProspectBL();
                    objUnreadUsersFromRepairProspectBL.User_id = iUserId;
                    objUnreadUsersFromRepairProspectBL.ShopID  = iShopId;
                    objUnreadUsersFromRepairProspectBL.Save();
                }
            }
            try
            {
                Int32 iPrivateLabelId = 0;
                if (Request.QueryString[Constants.QUERYSTRING_PRIVATELABELSHOPID] != null)
                {
                    Int32.TryParse(Request.QueryString[Constants.QUERYSTRING_PRIVATELABELSHOPID], out iPrivateLabelId);
                }
                else if (Request.Form[Constants.QUERYSTRING_PRIVATELABELSHOPID] != null)
                {
                    Int32.TryParse(Request.Form[Constants.QUERYSTRING_PRIVATELABELSHOPID], out iPrivateLabelId);
                }
                if (iPrivateLabelId == 0)
                {
                    return(false);
                }
                List <BodyShopPrivateLabelBL> lstBodyShopPrivateLabel = BodyShopPrivateLabelBL.GetShopListByPrivateLabelId(iPrivateLabelId);
                if (lstBodyShopPrivateLabel == null || lstBodyShopPrivateLabel.Count == 0)
                {
                    return(false);
                }
                List <MessageBL> lstMessage = MessageBL.getDataByUserIdAndType(iUserId, Constants.REGISTRATIONMESSAGTYPE);
                Boolean          bFound     = false;
                if (lstMessage != null && lstMessage.Count > 0)
                {
                    foreach (MessageBL objMessage in lstMessage)
                    {
                        if (objMessage.iShopID == null)
                        {
                            objMessage.bIsRead    = true;
                            objMessage.strMessage = Constants.REGISTRATIONMESSAGE;
                            if (iPrivateLabelId != 0)
                            {
                                objMessage.iPrivateLabelID = iPrivateLabelId;
                            }
                        }
                        else
                        {
                            objMessage.bIsRead    = false;
                            objMessage.iShopID    = iShopId;
                            objMessage.strMessage = Constants.PREFFEREDSHOPMESSAGE;
                            bFound = true;
                        }
                        objMessage.Save();
                    }
                }
                else
                {
                    MessageBL objMessage = new MessageBL();
                    objMessage.iPhoneUserID  = iUserId;
                    objMessage.iType         = Constants.REGISTRATIONMESSAGTYPE;
                    objMessage.strMessage    = Constants.REGISTRATIONMESSAGE;
                    objMessage.bIsRead       = false;
                    objMessage.dtMessageTime = DateTime.Now;
                    if (iPrivateLabelId != 0)
                    {
                        objMessage.iPrivateLabelID = iPrivateLabelId;
                    }
                    objMessage.Save();

                    MessageBL _objMessage = new MessageBL();
                    _objMessage.iShopID       = iShopId;
                    _objMessage.iPhoneUserID  = iUserId;
                    _objMessage.iType         = Constants.REGISTRATIONMESSAGTYPE;
                    _objMessage.strMessage    = Constants.PREFFEREDSHOPMESSAGE;
                    _objMessage.bIsRead       = false;
                    _objMessage.dtMessageTime = DateTime.Now;
                    _objMessage.Save();
                    bFound = true;
                }
                if (!bFound)
                {
                    MessageBL _objMessage = new MessageBL();
                    _objMessage.iShopID       = iShopId;
                    _objMessage.iPhoneUserID  = iUserId;
                    _objMessage.iType         = Constants.REGISTRATIONMESSAGTYPE;
                    _objMessage.strMessage    = Constants.PREFFEREDSHOPMESSAGE;
                    _objMessage.bIsRead       = false;
                    _objMessage.dtMessageTime = DateTime.Now;
                    _objMessage.Save();
                }
            }
            catch (Exception ex)
            {
            }
            return(false);
        }