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

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

            db.name        = model.db.name;
            db.note        = model.db.note;
            db.opc_client  = model.db.opc_client;
            db.update_by   = model.db.update_by;
            db.update_date = model.db.update_date;
            _context.SaveChanges();
            return(1);
        }
Exemple #3
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_opc_client_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");
            }

            var searchclient = repo.FindAll().Where(d => d.db.opc_client == item.db.opc_client && d.db.id != item.db.id).Count();

            if (searchclient > 0)
            {
                ModelState.AddModelError("db.opc_client", "existed");
            }
            return(ModelState.IsValid);
        }
Exemple #4
0
 private bool checkModelStateEdit(sys_opc_client_model item)
 {
     return(checkModelStateCreateEdit(ActionEnumForm.edit, item));
 }