Ejemplo n.º 1
0
        public async Task <int> insert_config(sys_item_bom_config_model model)
        {
            model.db.id = 0;
            await _context.sys_item_bom_configs.AddAsync(model.db);

            _context.SaveChanges();
            syncItem(model.db.id_item);
            return(1);
        }
Ejemplo n.º 2
0
        private bool checkModelStateCreateItemBomConfig(sys_item_bom_config_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            if (string.IsNullOrEmpty(item.db.id_item))
            {
                ModelState.AddModelError("db.id_item", "required");
            }


            var search = repo._context.sys_item_bom_configs.Where(d =>
                                                                  d.id_item == item.db.id_item &&
                                                                  d.name == item.db.name && d.id != item.db.id).Count();

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