public JsonResult Update([FromBody] EDMSMaterialProduct obj)
        {
            var msg = new JMessage {
                Title = "", Error = false
            };

            try
            {
                var item = _context.EDMSMaterialProducts.FirstOrDefault(x => x.ProductCode == obj.ProductCode);
                item.ProductName = obj.ProductName;
                item.Note        = obj.Note;
                item.Barcode     = obj.Barcode;
                item.GroupCode   = obj.GroupCode;
                item.TypeCode    = obj.TypeCode;
                item.Status      = obj.Status;
                //item.UpdatedBy = ESEIM.AppContext.UserName;
                item.UpdatedTime = DateTime.Now;
                _context.EDMSMaterialProducts.Update(item);
                _context.SaveChanges();
                msg.Title = "Cập nhập vật tư thành công";
            }
            catch
            {
                msg.Error = true;
                msg.Title = "Cập nhập vật tư lỗi!";
            }
            return(Json(msg));
        }
        public JsonResult Insert([FromBody] EDMSMaterialProduct obj)
        {
            var msg = new JMessage {
                Title = "", Error = false
            };

            try
            {
                var model = _context.EDMSMaterialProducts.Where(x => x.ProductCode.Equals(obj.ProductCode)).FirstOrDefault();
                if (model == null)
                {
                    //obj.CreatedBy = ESEIM.AppContext.UserName;
                    obj.CreatedTime = DateTime.Now;
                    _context.EDMSMaterialProducts.Add(obj);
                    _context.SaveChanges();
                    msg.Title = "Thêm vật tư thành công";
                }
                else
                {
                    msg.Error = true;
                    msg.Title = "Mã vật tư đã tồn tại!";
                }
            }
            catch
            {
                msg.Error = true;
                msg.Title = "Thêm vật tư lỗi!";
            }
            return(Json(msg));
        }