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

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

            db.status_del  = model.db.status_del;
            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);
        }
Beispiel #3
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_department_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);
        }
Beispiel #4
0
 private bool checkModelStateEdit(sys_department_model item)
 {
     return(checkModelStateCreateEdit(ActionEnumForm.edit, item));
 }