Пример #1
0
        public bool ModifyTransaction(string GroupId, long TransactionId, decimal points, tblAudit objAudit)
        {
            bool   status  = false;
            string connStr = objCustRepo.GetCustomerConnString(GroupId);

            using (var contextNew = new BOTSDBContext(connStr))
            {
                using (DbContextTransaction transaction = contextNew.Database.BeginTransaction())
                {
                    try
                    {
                        var objTransaction  = contextNew.TransactionMasters.Where(x => x.SlNo == TransactionId).FirstOrDefault();
                        var customerDetails = contextNew.CustomerDetails.Where(x => x.MobileNo == objTransaction.MobileNo).FirstOrDefault();
                        var PointExpiry     = contextNew.PointsExpiries.Where(x => x.MobileNo == objTransaction.MobileNo && x.Status == "00").ToList();
                        var NewPointExpiry  = contextNew.PointsExpiries.Where(x => x.MobileNo == objTransaction.MobileNo && x.Status == "00").OrderByDescending(y => y.ExpiryDate).FirstOrDefault();

                        var oldTransactionPoints = objTransaction.PointsEarned;

                        objTransaction.PointsEarned = points;
                        contextNew.TransactionMasters.AddOrUpdate(objTransaction);
                        contextNew.SaveChanges();

                        foreach (var item in PointExpiry)
                        {
                            item.Status = "01";
                            contextNew.PointsExpiries.AddOrUpdate(item);
                            contextNew.SaveChanges();
                        }

                        PointsExpiry objPointExpiry = new PointsExpiry();
                        objPointExpiry.Points     = (customerDetails.Points - oldTransactionPoints) + points;
                        objPointExpiry.CounterId  = NewPointExpiry.CounterId;
                        objPointExpiry.MobileNo   = NewPointExpiry.MobileNo;
                        objPointExpiry.Datetime   = DateTime.Now;
                        objPointExpiry.EarnDate   = NewPointExpiry.EarnDate;
                        objPointExpiry.ExpiryDate = NewPointExpiry.ExpiryDate;
                        objPointExpiry.Status     = "00";
                        objPointExpiry.InvoiceNo  = NewPointExpiry.InvoiceNo;
                        objPointExpiry.GroupId    = NewPointExpiry.GroupId;
                        objPointExpiry.CustomerId = NewPointExpiry.CustomerId;

                        contextNew.PointsExpiries.AddOrUpdate(objPointExpiry);
                        contextNew.SaveChanges();

                        customerDetails.Points = (customerDetails.Points - oldTransactionPoints) + points;
                        contextNew.CustomerDetails.AddOrUpdate(customerDetails);
                        contextNew.SaveChanges();

                        using (var context = new CommonDBContext())
                        {
                            context.tblAudits.Add(objAudit);
                            context.SaveChanges();
                        }
                        transaction.Commit();
                        status = true;
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        newexception.AddException(ex, GroupId);
                    }
                }
            }
            return(status);
        }
        public bool SubmitPoints(string MemberName, string Gender, string BirthDt, string mobileNo, string AnniversaryDt, string LiveIn, string Knowabt, string GroupId, string outletid)
        {
            bool status = false;
            // string smsresponce="";
            List <FeedBackMaster> lstfeedback          = new List <FeedBackMaster>();
            TransactionMaster     objtransactionMaster = new TransactionMaster();
            PointsExpiry          objpointsExpiry      = new PointsExpiry();
            CustomerDetail        objnewcust           = new CustomerDetail();
            string       connStr  = objCustRepo.GetCustomerConnString(GroupId);
            TimeZoneInfo IND_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
            DateTime     date     = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, IND_ZONE);

            using (var context = new BOTSDBContext(connStr))
            {
                CustomerDetail objcustdetails = context.CustomerDetails.Where(x => x.MobileNo == mobileNo).FirstOrDefault();
                OutletDetail   objoutlet      = context.OutletDetails.Where(x => x.OutletId == outletid).FirstOrDefault();
                FeedBackMaster objfeedback    = new FeedBackMaster();
                lstfeedback = context.FeedBackMasters.Where(x => x.MobileNo == mobileNo).OrderByDescending(y => y.DOJ).Take(2).ToList();
                if (objcustdetails != null)
                {
                    if (AnniversaryDt != null)
                    {
                        objcustdetails.AnniversaryDate = Convert.ToDateTime(AnniversaryDt);
                    }
                    var point = objcustdetails.Points;
                    objcustdetails.Points = point + objoutlet.FeedBackPoints;
                    context.CustomerDetails.AddOrUpdate(objcustdetails);
                    context.SaveChanges();
                }
                if (objcustdetails == null)
                {
                    var      CustomerId = context.CustomerDetails.OrderByDescending(x => x.CustomerId).Select(y => y.CustomerId).FirstOrDefault();
                    DateTime datet      = new DateTime(1900, 01, 01);
                    var      NewId      = Convert.ToInt64(CustomerId) + 1;
                    objnewcust.CustomerId = Convert.ToString(NewId);
                    objnewcust.Points     = objoutlet.FeedBackPoints;
                    if (string.IsNullOrEmpty(MemberName))
                    {
                        objnewcust.CustomerName = "Member";
                    }
                    else
                    {
                        objnewcust.CustomerName = MemberName;
                    }
                    objnewcust.CustomerCategory = null;
                    objnewcust.CardNumber       = "";
                    objnewcust.CustomerThrough  = "2";
                    if (BirthDt != "")
                    {
                        objnewcust.DOB = Convert.ToDateTime(BirthDt);
                    }
                    objnewcust.MaritalStatus = "";
                    objnewcust.MemberGroupId = "1000";
                    objnewcust.MobileNo      = mobileNo;
                    objnewcust.Status        = "00";
                    if (AnniversaryDt != null)
                    {
                        objnewcust.AnniversaryDate = Convert.ToDateTime(AnniversaryDt);
                    }
                    objnewcust.DOJ             = date;
                    objnewcust.EmailId         = "";
                    objnewcust.EnrollingOutlet = outletid;
                    if (string.IsNullOrEmpty(Gender))
                    {
                        objnewcust.Gender = "";
                    }
                    else
                    {
                        objnewcust.Gender = Gender;
                    }
                    objnewcust.IsSMS             = null;
                    objnewcust.BillingCustomerId = null;

                    context.CustomerDetails.Add(objnewcust);
                    context.SaveChanges();
                }
                if (objcustdetails != null)
                {
                    objtransactionMaster.CustomerId     = objcustdetails.CustomerId;
                    objtransactionMaster.CustomerPoints = objcustdetails.Points;
                }
                else
                {
                    objtransactionMaster.CustomerId     = objnewcust.CustomerId;
                    objtransactionMaster.CustomerPoints = objnewcust.Points;
                }

                objtransactionMaster.CounterId   = outletid + "01";
                objtransactionMaster.MobileNo    = mobileNo;
                objtransactionMaster.Datetime    = date;
                objtransactionMaster.TransType   = "1";
                objtransactionMaster.TransSource = "1";
                if (GroupId != "1163")
                {
                    objtransactionMaster.InvoiceNo = "B_Feedbackpoints";
                }
                else
                {
                    objtransactionMaster.InvoiceNo = "AabharBonus";
                }
                objtransactionMaster.InvoiceAmt     = 0;
                objtransactionMaster.Status         = "06";
                objtransactionMaster.PointsEarned   = objoutlet.FeedBackPoints;
                objtransactionMaster.PointsBurned   = 0;
                objtransactionMaster.CampaignPoints = 0;
                objtransactionMaster.TxnAmt         = 0;

                objtransactionMaster.Synchronization = "";
                objtransactionMaster.SyncDatetime    = null;

                if (GroupId != "1163")
                {
                    context.TransactionMasters.Add(objtransactionMaster);
                    context.SaveChanges();
                }
                if (lstfeedback.Count == 0 && GroupId == "1163")
                {
                    context.TransactionMasters.Add(objtransactionMaster);
                    context.SaveChanges();
                }

                objpointsExpiry.MobileNo  = mobileNo;
                objpointsExpiry.CounterId = outletid + "01";
                if (objcustdetails != null)
                {
                    objpointsExpiry.CustomerId = objcustdetails.CustomerId;
                }
                else
                {
                    objpointsExpiry.CustomerId = objnewcust.CustomerId;
                }

                objpointsExpiry.BurnDate = null;
                objpointsExpiry.Datetime = date;
                objpointsExpiry.EarnDate = date;
                // DateTime today = date;
                DateTime next         = date.AddYears(1);
                var      currentmonth = DateTime.DaysInMonth(next.Year, next.Month);

                if (next.Day < currentmonth)
                {
                    var days = (currentmonth - next.Day);
                    next = date.AddDays(days).AddYears(1);
                }
                objpointsExpiry.ExpiryDate = next;
                objpointsExpiry.Points     = objoutlet.FeedBackPoints;
                objpointsExpiry.Status     = "00";
                if (GroupId != "1163")
                {
                    objpointsExpiry.InvoiceNo = "B_Feedbackpoints";
                }
                else
                {
                    objpointsExpiry.InvoiceNo = "AabharBonus";
                }
                //objpointsExpiry.InvoiceNo = "B_Feedbackpoints";
                objpointsExpiry.GroupId           = objoutlet.GroupId;
                objpointsExpiry.OriginalInvoiceNo = "";
                objpointsExpiry.TransRefNo        = null;
                if (GroupId != "1163")
                {
                    context.PointsExpiries.Add(objpointsExpiry);
                    context.SaveChanges();
                }
                if (lstfeedback.Count == 0 && GroupId == "1163")
                {
                    context.PointsExpiries.Add(objpointsExpiry);
                    context.SaveChanges();
                }

                if (lstfeedback.Count == 0 && GroupId == "1163")
                {
                    FeedBackMaster feedback = new FeedBackMaster();
                    feedback.MobileNo       = mobileNo;
                    feedback.CustomerName   = MemberName;
                    feedback.OutletId       = outletid;
                    feedback.Location       = LiveIn;
                    feedback.HowToKonwAbout = Knowabt;
                    feedback.DOB            = Convert.ToDateTime(BirthDt);
                    if (AnniversaryDt != null)
                    {
                        feedback.DOA = Convert.ToDateTime(AnniversaryDt);
                    }
                    feedback.Points = objoutlet.FeedBackPoints;

                    context.FeedBackMasters.AddOrUpdate(feedback);
                    context.SaveChanges();
                    status = true;
                }
                else
                {
                    foreach (var feedback in lstfeedback)
                    {
                        feedback.Location       = LiveIn;
                        feedback.HowToKonwAbout = Knowabt;
                        if (BirthDt != "")
                        {
                            feedback.DOB = Convert.ToDateTime(BirthDt);
                        }
                        if (AnniversaryDt != null)
                        {
                            feedback.DOA = Convert.ToDateTime(AnniversaryDt);
                        }
                        feedback.Points = objoutlet.FeedBackPoints;

                        context.FeedBackMasters.AddOrUpdate(feedback);
                        context.SaveChanges();
                        status = true;
                    }
                }
                if (status)
                {
                    // string msgmobileno = "8452047477";
                    string               message1;
                    SMSDetail            objsmsdetails     = new SMSDetail();
                    FeedBackMobileMaster objmobilemaster   = new FeedBackMobileMaster();
                    SMSEmailMaster       objsmsemailmaster = new SMSEmailMaster();
                    if (GroupId != "1163")
                    {
                        objmobilemaster   = context.FeedBackMobileMasters.Where(x => x.MessageId == "202").FirstOrDefault();
                        objsmsemailmaster = context.SMSEmailMasters.Where(x => x.MessageId == "202").FirstOrDefault();
                        string message = objsmsemailmaster.SMS;
                        //TimeZoneInfo IND_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
                        //DateTime date = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, IND_ZONE);
                        if (objcustdetails != null)
                        {
                            message = message.Replace("#01", objcustdetails.CustomerName);
                        }
                        else
                        {
                            message = message.Replace("#01", "Member");
                        }

                        message = message.Replace("#30", mobileNo);
                        message = message.Replace("#08", Convert.ToString(date));

                        objsmsdetails = context.SMSDetails.Where(x => x.OutletId == outletid).FirstOrDefault();
                        // SendBulkSMSMessageTxn(objmobilemaster.MobileNo, objsmsdetails.SenderId, message);
                        SendBulkSMSMessagevision(objmobilemaster.MobileNo, objsmsdetails.SenderId, message);
                    }
                    objsmsemailmaster = context.SMSEmailMasters.Where(x => x.MessageId == "201").FirstOrDefault();
                    message1          = objsmsemailmaster.SMS;
                    if (objcustdetails != null)
                    {
                        message1 = message1.Replace("#01", objcustdetails.CustomerName);
                    }
                    else
                    {
                        message1 = message1.Replace("#01", "Member");
                    }
                    // SendMessage(mobileNo, objsmsdetails.SenderId, message1, objsmsdetails.TxnUrl, objsmsdetails.TxnUserName, objsmsdetails.TxnPassword);
                    SendMessageVision(objsmsdetails.TxnUrl, mobileNo, message1, objsmsdetails.SenderId, objsmsdetails.TxnPassword);
                }
            }
            return(status);
        }
        public string SubmitRating(string mobileNo, int[] ranking, string GroupId, string outletId)
        {
            string status = "false";
            // string smsresponce = "";
            FeedBackMaster objfeedback = new FeedBackMaster();
            string         connStr     = objCustRepo.GetCustomerConnString(GroupId);
            TimeZoneInfo   IND_ZONE    = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
            DateTime       date        = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, IND_ZONE);

            using (var context = new BOTSDBContext(connStr))
            {
                CustomerDetail    objcustdetails       = context.CustomerDetails.Where(x => x.MobileNo == mobileNo).FirstOrDefault();
                OutletDetail      objoutlet            = context.OutletDetails.Where(x => x.OutletId == outletId).FirstOrDefault();
                TransactionMaster objtransactionMaster = new TransactionMaster();
                PointsExpiry      objpointsExpiry      = new PointsExpiry();
                var transaction   = context.TransactionMasters.Where(x => x.MobileNo == mobileNo).OrderByDescending(y => y.Datetime).Take(2).ToList();
                var pointexpiry   = context.PointsExpiries.Where(x => x.MobileNo == mobileNo).OrderByDescending(y => y.Datetime).Take(2).ToList();
                int queid         = 1;
                int Combinedpoint = 0;
                foreach (int points in ranking)
                {
                    if (points != 0)
                    {
                        if (objcustdetails != null)
                        {
                            objfeedback.CustomerName = objcustdetails.CustomerName;
                        }
                        else
                        {
                            objfeedback.CustomerName = "Member";
                        }
                        objfeedback.MobileNo       = mobileNo;
                        objfeedback.QuestionPoints = points.ToString();
                        objfeedback.QuestionId     = queid.ToString();
                        objfeedback.OutletId       = outletId;

                        objfeedback.DOJ = date;
                        Combinedpoint  += points;
                        objfeedback     = context.FeedBackMasters.Add(objfeedback);
                        context.SaveChanges();
                        status = "true";
                    }
                    queid++;
                }
                if (Combinedpoint <= 4)
                {
                    SMSDetail            objsmsdetails     = new SMSDetail();
                    FeedBackMobileMaster objmobilemaster   = context.FeedBackMobileMasters.Where(x => x.MessageId == "203").FirstOrDefault();
                    SMSEmailMaster       objsmsemailmaster = context.SMSEmailMasters.Where(x => x.MessageId == "203").FirstOrDefault();


                    string message = objsmsemailmaster.SMS;
                    if (objcustdetails != null)
                    {
                        message = message.Replace("#01", objcustdetails.CustomerName);
                    }
                    else
                    {
                        message = message.Replace("#01", "Member");
                    }

                    message = message.Replace("#30", mobileNo);
                    message = message.Replace("#08", Convert.ToString(date));
                    message = message.Replace("#31", Convert.ToString(ranking[0]));
                    message = message.Replace("#32", Convert.ToString(ranking[1]));

                    objsmsdetails = context.SMSDetails.Where(x => x.OutletId == outletId).FirstOrDefault();
                    // SendMessage(objmobilemaster.MobileNo, objsmsdetails.SenderId, message, objsmsdetails.TxnUrl, objsmsdetails.TxnUserName, objsmsdetails.TxnPassword);
                    SendMessageVision(objsmsdetails.TxnUrl, objmobilemaster.MobileNo, message, objsmsdetails.SenderId, objsmsdetails.TxnPassword);
                }
                if (transaction.Count > 0)
                {
                    if (transaction[0].InvoiceNo == "B_Feedbackpoints" && pointexpiry[0].InvoiceNo == "B_Feedbackpoints")
                    {
                        var point = objcustdetails.Points;
                        objcustdetails.Points = point + objoutlet.FeedBackPoints;
                        context.CustomerDetails.AddOrUpdate(objcustdetails);
                        context.SaveChanges();
                        objtransactionMaster.CustomerId      = objcustdetails.CustomerId;
                        objtransactionMaster.CustomerPoints  = objcustdetails.Points;
                        objtransactionMaster.CounterId       = outletId + "01";
                        objtransactionMaster.MobileNo        = mobileNo;
                        objtransactionMaster.Datetime        = date;
                        objtransactionMaster.TransType       = "1";
                        objtransactionMaster.TransSource     = "1";
                        objtransactionMaster.InvoiceNo       = "B_Feedbackpoints";
                        objtransactionMaster.InvoiceAmt      = 0;
                        objtransactionMaster.Status          = "06";
                        objtransactionMaster.PointsEarned    = objoutlet.FeedBackPoints;
                        objtransactionMaster.PointsBurned    = 0;
                        objtransactionMaster.CampaignPoints  = 0;
                        objtransactionMaster.TxnAmt          = 0;
                        objtransactionMaster.Synchronization = "";
                        objtransactionMaster.SyncDatetime    = null;
                        context.TransactionMasters.Add(objtransactionMaster);
                        context.SaveChanges();
                        objpointsExpiry.MobileNo   = mobileNo;
                        objpointsExpiry.CounterId  = outletId + "01";
                        objpointsExpiry.CustomerId = objcustdetails.CustomerId;
                        objpointsExpiry.BurnDate   = null;
                        objpointsExpiry.Datetime   = date;
                        objpointsExpiry.EarnDate   = date;
                        // DateTime today = date;
                        DateTime next         = date.AddYears(1);
                        var      currentmonth = DateTime.DaysInMonth(next.Year, next.Month);

                        if (next.Day < currentmonth)
                        {
                            var days = (currentmonth - next.Day);
                            next = date.AddDays(days).AddYears(1);
                        }
                        objpointsExpiry.ExpiryDate        = next;
                        objpointsExpiry.Points            = objoutlet.FeedBackPoints;
                        objpointsExpiry.Status            = "00";
                        objpointsExpiry.InvoiceNo         = "B_Feedbackpoints";
                        objpointsExpiry.GroupId           = objoutlet.GroupId;
                        objpointsExpiry.OriginalInvoiceNo = "";
                        objpointsExpiry.TransRefNo        = null;
                        context.PointsExpiries.Add(objpointsExpiry);
                        context.SaveChanges();
                        status = "pointsGiven";
                    }
                }
            }
            return(status);
        }
Пример #4
0
        public int AddpointsToExistingCust(string mobileNo, string BeneficiaryId, string Name)
        {
            int                      result               = 0;
            CustomerDetails          objcustomerDetails   = new CustomerDetails();
            List <TransactionMaster> lsttransaction       = new List <TransactionMaster>();
            TransactionMaster        objtransactionMaster = new TransactionMaster();
            PointsExpiry             objpointsExpiry      = new PointsExpiry();

            List <PointsExpiry> lstpointsExpiry = new List <PointsExpiry>();

            try
            {
                using (var contextNew = new ChitaleBCContext())
                {
                    CustomerBeneficiaryDetail objcustomerBeneficiaryDetail = new CustomerBeneficiaryDetail();
                    objcustomerBeneficiaryDetail = contextNew.CustomerBeneficiaryDetails.Where(x => x.MobileNo == mobileNo).FirstOrDefault();
                    objcustomerDetails           = contextNew.CustomerDetails.Where(x => x.MobileNo == mobileNo).FirstOrDefault();
                    if (objcustomerBeneficiaryDetail != null)
                    {
                        result = 0;
                    }
                    else
                    {
                        objcustomerBeneficiaryDetail = contextNew.CustomerBeneficiaryDetails.Where(x => x.BeneficiaryId == BeneficiaryId).FirstOrDefault();
                        if (objcustomerBeneficiaryDetail != null)
                        {
                            result = 1;
                        }
                        else
                        {
                            if (objcustomerDetails != null)
                            {
                                var point = objcustomerDetails.Points;
                                objcustomerDetails.Points = point + 100;
                                contextNew.CustomerDetails.AddOrUpdate(objcustomerDetails);
                                contextNew.SaveChanges();

                                objtransactionMaster.CustomerId       = objcustomerDetails.CustomerId;
                                objtransactionMaster.CounterId        = "1088101001";
                                objtransactionMaster.MobileNo         = mobileNo;
                                objtransactionMaster.Datetime         = DateTime.Now;
                                objtransactionMaster.TransType        = "1";
                                objtransactionMaster.TransSource      = "1";
                                objtransactionMaster.InvoiceNo        = "B_CovidPoints";
                                objtransactionMaster.InvoiceAmt       = 0;
                                objtransactionMaster.Status           = "06";
                                objtransactionMaster.PointsEarned     = 100;
                                objtransactionMaster.PointsBurned     = 0;
                                objtransactionMaster.CampaignPoints   = 0;
                                objtransactionMaster.TxnAmt           = 0;
                                objtransactionMaster.CustomerPoints   = objcustomerDetails.Points;
                                objtransactionMaster.Synchronization  = "";
                                objtransactionMaster.SyncDatetime     = null;
                                objtransactionMaster.BillType         = "";
                                objtransactionMaster.ChitaleTxnStatus = "";

                                contextNew.TransactionMasters.Add(objtransactionMaster);
                                contextNew.SaveChanges();

                                lstpointsExpiry            = contextNew.PointsExpiries.Where(x => x.MobileNo == mobileNo).ToList();
                                objpointsExpiry.MobileNo   = mobileNo;
                                objpointsExpiry.CounterId  = "1088101001";
                                objpointsExpiry.CustomerId = objcustomerDetails.CustomerId;
                                objpointsExpiry.BurnDate   = null;
                                objpointsExpiry.Datetime   = DateTime.Now;
                                objpointsExpiry.EarnDate   = DateTime.Now;
                                DateTime today        = DateTime.Today;
                                DateTime next         = today.AddYears(1);
                                var      currentmonth = DateTime.DaysInMonth(next.Year, next.Month);

                                if (next.Day < currentmonth)
                                {
                                    var days = (currentmonth - next.Day);
                                    next = today.AddDays(days).AddYears(1);
                                }
                                objpointsExpiry.ExpiryDate        = next;
                                objpointsExpiry.Points            = 100;
                                objpointsExpiry.Status            = "00";
                                objpointsExpiry.InvoiceNo         = "B_CovidPoints";
                                objpointsExpiry.GroupId           = "1088";
                                objpointsExpiry.OriginalInvoiceNo = "";
                                objpointsExpiry.TransRefNo        = null;

                                contextNew.PointsExpiries.Add(objpointsExpiry);
                                contextNew.SaveChanges();
                                CustomerBeneficiaryDetail objcustomerBeneficiaryDetail1 = new CustomerBeneficiaryDetail();

                                objcustomerBeneficiaryDetail1.BeneficiaryId = BeneficiaryId;
                                objcustomerBeneficiaryDetail1.CustomerId    = objcustomerDetails.CustomerId;
                                objcustomerBeneficiaryDetail1.CustomerName  = Name;
                                objcustomerBeneficiaryDetail1.MobileNo      = mobileNo;
                                objcustomerBeneficiaryDetail1.Points        = Convert.ToDecimal(objcustomerDetails.Points);
                                objcustomerBeneficiaryDetail1.EnrolledDate  = DateTime.Now;

                                contextNew.CustomerBeneficiaryDetails.Add(objcustomerBeneficiaryDetail1);
                                contextNew.SaveChanges();
                                result = 2;
                            }
                            else
                            {
                                CustomerDetails           objcustomerDetail             = new CustomerDetails();
                                CustomerBeneficiaryDetail objcustomerBeneficiaryDetails = new CustomerBeneficiaryDetail();
                                var ObjMobileNo = contextNew.CustomerDetails.Where(x => x.MobileNo == mobileNo).FirstOrDefault();
                                if (ObjMobileNo == null)
                                {
                                    var      CustomerId = contextNew.CustomerDetails.OrderByDescending(x => x.CustomerId).Select(y => y.CustomerId).FirstOrDefault();
                                    DateTime datet      = new DateTime(1900, 01, 01);
                                    var      NewId      = Convert.ToInt64(CustomerId) + 1;
                                    objcustomerDetail.CustomerId       = Convert.ToString(NewId);
                                    objcustomerDetail.Points           = 100;
                                    objcustomerDetail.CustomerName     = Name;
                                    objcustomerDetail.CustomerCategory = null;
                                    objcustomerDetail.CardNumber       = "";
                                    objcustomerDetail.CustomerThrough  = "2";
                                    objcustomerDetail.DOB               = datet;
                                    objcustomerDetail.MaritalStatus     = "";
                                    objcustomerDetail.MemberGroupId     = "1000";
                                    objcustomerDetail.MobileNo          = mobileNo;
                                    objcustomerDetail.Status            = "00";
                                    objcustomerDetail.AnniversaryDate   = datet;
                                    objcustomerDetail.DOJ               = DateTime.Now;
                                    objcustomerDetail.EmailId           = "";
                                    objcustomerDetail.EnrollingOutlet   = "10881010";
                                    objcustomerDetail.Gender            = "";
                                    objcustomerDetail.IsSMS             = null;
                                    objcustomerDetail.BillingCustomerId = null;


                                    //objcustomerDetails.
                                    contextNew.CustomerDetails.Add(objcustomerDetail);
                                    contextNew.SaveChanges();

                                    objtransactionMaster.CustomerId       = objcustomerDetail.CustomerId;
                                    objtransactionMaster.CounterId        = "1088101001";
                                    objtransactionMaster.MobileNo         = mobileNo;
                                    objtransactionMaster.Datetime         = DateTime.Now;
                                    objtransactionMaster.TransType        = "1";
                                    objtransactionMaster.TransSource      = "1";
                                    objtransactionMaster.InvoiceNo        = "B_CovidPoints";
                                    objtransactionMaster.InvoiceAmt       = 0;
                                    objtransactionMaster.Status           = "06";
                                    objtransactionMaster.PointsEarned     = 100;
                                    objtransactionMaster.PointsBurned     = 0;
                                    objtransactionMaster.CampaignPoints   = 0;
                                    objtransactionMaster.TxnAmt           = 0;
                                    objtransactionMaster.CustomerPoints   = objcustomerDetail.Points;
                                    objtransactionMaster.Synchronization  = "";
                                    objtransactionMaster.SyncDatetime     = null;
                                    objtransactionMaster.BillType         = "";
                                    objtransactionMaster.ChitaleTxnStatus = "";

                                    contextNew.TransactionMasters.AddOrUpdate(objtransactionMaster);
                                    contextNew.SaveChanges();

                                    lstpointsExpiry            = contextNew.PointsExpiries.Where(x => x.MobileNo == mobileNo).ToList();
                                    objpointsExpiry.MobileNo   = mobileNo;
                                    objpointsExpiry.CounterId  = "1088101001";
                                    objpointsExpiry.CustomerId = objcustomerDetail.CustomerId;
                                    objpointsExpiry.BurnDate   = null;
                                    objpointsExpiry.Datetime   = DateTime.Now;
                                    objpointsExpiry.EarnDate   = DateTime.Now;
                                    DateTime today        = DateTime.Today;
                                    DateTime next         = today.AddYears(1);
                                    var      currentmonth = DateTime.DaysInMonth(next.Year, next.Month);

                                    if (next.Day < currentmonth)
                                    {
                                        var days = (currentmonth - next.Day);
                                        next = today.AddDays(days).AddYears(1);
                                    }
                                    objpointsExpiry.ExpiryDate        = next;
                                    objpointsExpiry.Points            = 100;
                                    objpointsExpiry.Status            = "00";
                                    objpointsExpiry.InvoiceNo         = "B_CovidPoints";
                                    objpointsExpiry.GroupId           = "1088";
                                    objpointsExpiry.OriginalInvoiceNo = "";
                                    objpointsExpiry.TransRefNo        = null;

                                    contextNew.PointsExpiries.AddOrUpdate(objpointsExpiry);
                                    contextNew.SaveChanges();

                                    objcustomerBeneficiaryDetails.BeneficiaryId = BeneficiaryId;
                                    objcustomerBeneficiaryDetails.CustomerId    = objcustomerDetail.CustomerId;
                                    objcustomerBeneficiaryDetails.CustomerName  = Name;
                                    objcustomerBeneficiaryDetails.MobileNo      = mobileNo;
                                    objcustomerBeneficiaryDetails.Points        = Convert.ToDecimal(objcustomerDetail.Points);
                                    objcustomerBeneficiaryDetails.EnrolledDate  = DateTime.Now;

                                    contextNew.CustomerBeneficiaryDetails.AddOrUpdate(objcustomerBeneficiaryDetails);
                                    contextNew.SaveChanges();
                                    result = 2;
                                }
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                //newexception.AddException(ex);
            }
            return(result);
        }