Esempio n. 1
0
        /// <summary>
        /// Method is used to insert the customer details in DB
        /// </summary>
        /// <param name="customer"></param>
        public void InsertCustomerDetails(CustomerModelLib.Customer customer)
        {
            List <string> CustomerEmails = GetCustomer();

            try
            {
                if (!IsCustomerExist(customer.EmailId, CustomerEmails))
                {
                    using (ChatBotDataModelDataContext dbcontext = new ChatBotDataModelDataContext())
                    {
                        ChatBotModelLib.Customer customerObj = new ChatBotModelLib.Customer();
                        customerObj.customer_email = customer.EmailId;
                        customerObj.customer_name  = customer.Name;
                        customerObj.customer_phone = customer.Phone;
                        dbcontext.Customers.InsertOnSubmit(customerObj);
                        dbcontext.SubmitChanges();
                    }
                }
                int MonitorNo = GetMonitorIdByMonitorName(customer.MonitorName);
                InsertCustomerPreference(customer.EmailId, MonitorNo);
            }
            catch (Exception ex)
            {
#pragma warning disable S3445 // Exceptions should not be explicitly rethrown
                throw ex;
#pragma warning restore S3445 // Exceptions should not be explicitly rethrown
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Method is used for inserting the customer and thier Monitor preference
 /// </summary>
 /// <param name="email"></param>
 /// <param name="monitor_no"></param>
 private void InsertCustomerPreference(string email, int monitor_no)
 {
     using (ChatBotDataModelDataContext dbcontext = new ChatBotDataModelDataContext())
     {
         ChatBotModelLib.MonitorsPreference monitorObj = new ChatBotModelLib.MonitorsPreference();
         monitorObj.customer_email = email;
         monitorObj.monitors_no    = monitor_no;
         monitorObj.check_in       = DateTime.Now;
         dbcontext.MonitorsPreferences.InsertOnSubmit(monitorObj);
         dbcontext.SubmitChanges();
     }
 }
Esempio n. 3
0
        public List <string> GetAllSelectedItems(int Feature_No, string FeatureValue)
        {
            var    FeatureDictionary = dataref.ReadAttributes();
            string Feature;

            if (Feature_No == 0)
            {
                Feature = "FirstFeature";
            }
            else
            {
                try
                {
                    Feature = FeatureDictionary[Feature_No];
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            List <string> Selectedlist = new List <string>();

            if (!Feature.Equals(string.Empty) && !FeatureValue.Equals(string.Empty))
            {
                using (ChatBotDataModelDataContext dbcontext = new ChatBotDataModelDataContext())
                {
                    if (Feature.Equals("FirstFeature") && FeatureValue.Equals("FirstValue"))
                    {
                        var Selectedtems = dbcontext.ChatbotTable_s.Select("monitors_name");
                        foreach (var Item in Selectedtems)
                        {
                            Selectedlist.Add(Item.ToString());
                        }
                    }
                    else
                    {
                        var Selectedtems = dbcontext.ChatbotTable_s.Where(Feature + "=\"" + FeatureValue + "\"").Select("monitors_name");
                        foreach (var Item in Selectedtems)
                        {
                            Selectedlist.Add(Item.ToString());
                        }
                    }
                }
            }
            else
            {
                throw new ArgumentException("String Empty");
            }
            return(Selectedlist);
        }
Esempio n. 4
0
        /// <summary>
        /// Method is used to get all the customer from the Db
        /// </summary>
        /// <returns>list of customer</returns>
        public List <string> GetCustomer()
        {
            List <string> CustomerEmails = new List <string>();

            using (ChatBotDataModelDataContext dbcontext = new ChatBotDataModelDataContext())
            {
                IQueryable SelectedCustomersEmail = dbcontext.Customers.Select("customer_email");
                foreach (var email in SelectedCustomersEmail)
                {
                    CustomerEmails.Add(email.ToString());
                }
                return(CustomerEmails);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Method  is used to get monitor no from the DB.
 /// </summary>
 /// <param name="monitorName"></param>
 /// <returns>monitor nomber</returns>
 private int GetMonitorIdByMonitorName(string monitorName)
 {
     using (ChatBotDataModelDataContext dbcontext = new ChatBotDataModelDataContext())
     {
         string MonitorNameFeild = "monitors_name";
         string MonitorNumber    = null;
         var    number           = dbcontext.Monitors.Where(MonitorNameFeild + "=\"" + monitorName + "\"").Select("monitors_no");
         foreach (var item in number)
         {
             MonitorNumber = item.ToString();
         }
         return(int.Parse(MonitorNumber));
     }
 }
Esempio n. 6
0
        public Dictionary <int, string> ReadAttributes()
        {
            Dictionary <int, string> FeaturesDictionary = new Dictionary <int, string>();

            using (ChatBotDataModelDataContext dbcontext = new ChatBotDataModelDataContext())
            {
                var columnnames = from t in typeof(Monitor).GetProperties() select t.Name;
                int i           = 0;
                foreach (var c in columnnames)
                {
                    FeaturesDictionary.Add(i, c.ToString());
                    i = i + 1;
                }
            }
            return(FeaturesDictionary);
        }
Esempio n. 7
0
        public List <string> ReadData(Dictionary <int, string> FeaturesDictionary, Dictionary <int, string> AnswerDictionary, int QuestionNumber)
        {
            List <string> options = new List <string>();

            using (ChatBotDataModelDataContext dbcontext = new ChatBotDataModelDataContext())
            {
                IQueryable optionsQueryable;
                if (QuestionNumber == 1)
                {
                    optionsQueryable = dbcontext.Monitors.Where(FeaturesDictionary[QuestionNumber] + "!=\"" + null + "\"").Select(FeaturesDictionary[QuestionNumber]).Distinct();
                }
                else
                {
                    int feature_no = AnswerDictionary.Keys.Max();
                    optionsQueryable = dbcontext.Monitors.Where(FeaturesDictionary[feature_no] + "=\"" + AnswerDictionary[feature_no] + "\"").Where(FeaturesDictionary[QuestionNumber] + "!=\"" + null + "\"").Select(FeaturesDictionary[QuestionNumber]).Distinct();
                }
                foreach (var option in optionsQueryable)
                {
                    options.Add(option.ToString());
                }
                return(options);
            }
        }