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

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

            db.name            = model.db.name;
            db.interval_second = model.db.interval_second;
            db.keep_record     = model.db.keep_record;
            db.opc_node_id     = model.db.opc_node_id;
            db.update_by       = model.db.update_by;

            db.note        = model.db.note;
            db.update_date = model.db.update_date;
            _context.SaveChanges();
            return(1);
        }
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_template_opc_param_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");
            }

            if (string.IsNullOrEmpty(item.db.opc_node_id))
            {
                ModelState.AddModelError("db.opc_node_id", "required");
            }
            return(ModelState.IsValid);
        }
 private bool checkModelStateEdit(sys_template_opc_param_model item)
 {
     return(checkModelStateCreateEdit(ActionEnumForm.edit, item));
 }