예제 #1
0
        public static bool AddLookUpModel(LookUpModel lookUpModel)
        {
            bool isSaved = false ;
            try
            {
                using (var db = new PosEntities())
                {
                    if (lookUpModel != null)
                    {
                        db.LookUps.Add(new LookUp { FieldDescription = lookUpModel.FieldDescription, FieldName = lookUpModel.FieldName, FieldValue = lookUpModel.FieldValue, LookupID = lookUpModel.LookUpID, SortOrder = lookUpModel.SortOrder });
                       var result =  db.SaveChanges();

                        isSaved = result > 0 ?  true  : false  ;
                    }
                }

            }
            catch (Exception)
            {
                isSaved = false;
                //throw;
            }
            return isSaved;
        }
예제 #2
0
 public static bool UpdateLookUpModel(LookUpModel lookUpModel)
 {
     bool isSaved = false;
     try
     {
         using (var db = new PosEntities())
         {
             var lookup = db.LookUps.FirstOrDefault(l => l.LookupID == lookUpModel.LookUpID);
             if (lookUpModel != null)
             {
                     lookup.FieldDescription = lookUpModel.FieldDescription;
                     lookup.FieldName = lookUpModel.FieldName;
                     lookup.FieldValue = lookUpModel.FieldValue;
                     lookup.SortOrder = lookUpModel.SortOrder;
                     var result = db.SaveChanges();
                     isSaved = result > 0 ? true : false;
             }
         }
     }
     catch (Exception)
     {
         isSaved = false;
         //throw;
     }
     return isSaved;
 }