Exemple #1
0
 public static bool UpdateCategory(DBO.Category category)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Category t_category = bdd.T_Category.Where(x => x.id == category.Id).FirstOrDefault();
             if (t_category != null)
             {
                 t_category.id   = category.Id;
                 t_category.name = category.Name;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Exemple #2
0
 public static bool CreateCategory(DBO.Category category)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Category t_category = new T_Category()
             {
                 id   = category.Id,
                 name = category.Name
             };
             bdd.T_Category.Add(t_category);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }