Exemplo n.º 1
0
        public static void SoftDelete(int id)
        {
            SinaicspDataModelContainer _context = new Sinaicsp_API.SinaicspDataModelContainer();
            SchoolYear _item = _context.SchoolYears.FirstOrDefault(a => a.Id == id);

            _item.IsDeleted = true;
            _context.SaveChanges();
        }
Exemplo n.º 2
0
        public static bool Update(int id, string name)
        {
            SinaicspDataModelContainer _context = new Sinaicsp_API.SinaicspDataModelContainer();
            SchoolYear itemById   = _context.SchoolYears.FirstOrDefault(a => a.Id == id);
            SchoolYear itemByName = _context.SchoolYears.ToList().FirstOrDefault(a => a.Name.ToLower() == name.ToLower());

            if (itemByName == null || itemByName.Id == itemById.Id)
            {
                SchoolYear _item = itemById;
                _item.Name = name;
                _context.SaveChanges();
                return(true);
            }
            return(false);
        }