コード例 #1
0
        /// <summary>
        /// Save message for new oppurtunity to shop user
        /// </summary>
        /// <param name="iUserId"></param>
        /// <param name="ZipCode"></param>
        private void performPostOperation(Int32 iUserId, String ZipCode)
        {
            try
            {
                //Check user is from private label app
                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);
                }

                saveMessage(iUserId, iPrivateLabelId);



                UserBL objUser = UserBL.getByActivityId(iUserId);

                if (objUser != null && Convert.ToBoolean(objUser.bIsRegistred_Shop))
                {
                    //Send Zip Code matches messages to customer configured by shops
                    SendZipCodeMatchesShopSMS(objUser.ID, objUser.strZip, iPrivateLabelId);

                    DeletedUsersFromRepairProspectBL.DeleteAllByUserId(iUserId);
                    Int32 iShopId;
                    if (checkUserPrefferedShop(iUserId, out iShopId))
                    {
                        UnreadUsersFromRepairProspectBL objOldEntry = UnreadUsersFromRepairProspectBL.getDataByShopId(iShopId, iUserId);
                        if (objOldEntry == null)
                        {
                            UnreadUsersFromRepairProspectBL obj = new UnreadUsersFromRepairProspectBL();
                            obj.ShopID  = iShopId;
                            obj.User_id = iUserId;
                            obj.Save();
                        }
                    }
                    else
                    {
                        List <UnreadUsersFromRepairProspectBL> lstUnreadUsersFromRepairProspectBL = UnreadUsersFromRepairProspectBL.getDataByUnReadUsers(ZipCode, iUserId);
                        foreach (UnreadUsersFromRepairProspectBL objUnreadUsersFromRepairProspectBL in lstUnreadUsersFromRepairProspectBL)
                        {
                            UnreadUsersFromRepairProspectBL objOldEntry = UnreadUsersFromRepairProspectBL.getDataByShopId(objUnreadUsersFromRepairProspectBL.ShopID.Value, objUnreadUsersFromRepairProspectBL.User_id.Value);
                            if (objOldEntry == null)
                            {
                                UnreadUsersFromRepairProspectBL obj = new UnreadUsersFromRepairProspectBL();
                                obj.ShopID  = objUnreadUsersFromRepairProspectBL.ShopID;
                                obj.User_id = objUnreadUsersFromRepairProspectBL.User_id;
                                obj.Save();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #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);
        }