//List<TopCustomersEntity> GetPandSList(string jsonData)

        public bool SaveSearchJson(string jsonSearch, int ScreenId, string ScreenName)
        {
            try
            {
                var result = entities.LastSelectionHistories.Where(x => x.Screen_Id == ScreenId).FirstOrDefault();
                if (result != null)
                {
                    result.Last_Selection = jsonSearch;
                    result.Last_Updated   = DateTime.Now;
                    entities.SaveChanges();
                    return(true);
                }
                else
                {
                    LastSelectionHistory lastSelection = new LastSelectionHistory()
                    {
                        Screen_Id      = ScreenId,
                        Screen_Name    = ScreenName,
                        Last_Selection = jsonSearch,
                        Last_Updated   = DateTime.Now
                    };
                    entities.LastSelectionHistories.Add(lastSelection);
                    entities.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 2
0
        public bool RefreshCustomer(int custId)
        {
            bool result = false;

            try
            {
                using (SDNCustomersDBEntities entities = new SDNCustomersDBEntities())
                {
                    var obj = entities.Customers.Where(x => x.IsRefreshed == true).FirstOrDefault();
                    if (obj != null)
                    {
                        obj.IsRefreshed = false;
                        entities.SaveChanges();
                    }
                    var obj2 = entities.Customers.Where(x => x.ID == custId).FirstOrDefault();
                    if (obj2 != null)
                    {
                        obj2.IsRefreshed   = true;
                        obj2.RefreshedDate = System.DateTime.UtcNow;
                        entities.SaveChanges();
                    }
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Esempio n. 3
0
 public int CreateCustomer(Customer entity)
 {
     using (SDNCustomersDBEntities entities = new SDNCustomersDBEntities())
     {
         if (entities.Customers.AsNoTracking().FirstOrDefault(x => x.ID == entity.ID) == null)
         {
             entities.Customers.Add(entity);
         }
         else
         {
             entities.Entry(entity).State = EntityState.Modified;
         }
         return(entities.SaveChanges());
     }
 }
Esempio n. 4
0
        public bool DeleteCustomer(int custId)
        {
            bool result = false;

            try
            {
                using (SDNCustomersDBEntities entities = new SDNCustomersDBEntities())
                {
                    var obj = entities.Customers.Where(x => x.ID == custId).FirstOrDefault();
                    entities.Customers.Remove(obj);
                    entities.SaveChanges();
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }