public async Task <int> insert(sys_unit_model model)
        {
            await _context.sys_units.AddAsync(model.db);

            _context.SaveChanges();
            return(1);
        }
        public int update(sys_unit_model model)
        {
            var db = _context.sys_units.Where(d => d.id == model.db.id).FirstOrDefault();

            db.name        = model.db.name;
            db.note        = model.db.note;
            db.update_by   = model.db.update_by;
            db.update_date = model.db.update_date;
            _context.SaveChanges();
            return(1);
        }
Example #3
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_unit_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            var search = repo.FindAll().Where(d => d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }


            return(ModelState.IsValid);
        }
Example #4
0
 private bool checkModelStateEdit(sys_unit_model item)
 {
     return(checkModelStateCreateEdit(ActionEnumForm.edit, item));
 }