Exemple #1
0
        //Edit
        public void EditCategories(CategoriesCustomClass category)
        {
            var result = _db.categories.FirstOrDefault(e => e.Id == category.Id);

            if (!Exist(category))
            {
                result.name = category.Name;
            }
            _db.SaveChanges();
        }
Exemple #2
0
 //Create
 public void CreateCategories(CategoriesCustomClass category)
 {
     if (!Exist(category))
     {
         _db.categories.Add(new categories()
         {
             name = category.Name,
             Id   = category.Id
         });
     }
     _db.SaveChanges();
 }
Exemple #3
0
 public bool Exist(CategoriesCustomClass category)
 {
     return(_db.categories.FirstOrDefault(e => e.name == category.Name) == null ? false : true);
 }