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

            try
            {
                var query = _context.MaterialStoreExpGoodsHeaders.FirstOrDefault(x => x.ExpCode.Equals(obj.ExpCode));
                if (query == null)
                {
                    var temp = new MaterialStoreExpGoodsHeader
                    {
                        ExpCode       = obj.ExpCode,
                        SupplierId    = obj.SupplierId,
                        UserId        = obj.UserId,
                        Total         = obj.Total,
                        TotalPayment  = obj.TotalPayment,
                        Vat           = obj.Vat,
                        TotalPayed    = obj.TotalPayed,
                        ShipperId     = obj.ShipperId,
                        StoreId       = obj.StoreId,
                        TimeImpCreate = !string.IsNullOrEmpty(obj.TimeImpCreate) ? DateTime.ParseExact(obj.TimeImpCreate, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null,
                        InsurantTime  = !string.IsNullOrEmpty(obj.InsurantTime) ? DateTime.ParseExact(obj.InsurantTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null,
                        Debt          = obj.Debt,
                        Note          = obj.Note,
                    };
                    _context.MaterialStoreExpGoodsHeaders.Add(temp);
                    _context.SaveChanges();
                    msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("MES_TITLE_INFORMATION_EXPSTORE"));
                }
                else
                {
                    msg.Error = true;
                    msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_EXITS"), CommonUtil.ResourceValue("MES_TITLE_INFORMATION_EXPSTORE"));
                }
            }
            catch (Exception ex)
            {
                msg.Error = true;
                msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_FAILED"), CommonUtil.ResourceValue("MES_TITLE_INFORMATION_EXPSTORE"));
            }
            return(Json(msg));
        }
        public JsonResult Update([FromBody] MaterialStoreExpModel obj)
        {
            var msg = new JMessage()
            {
                Error = false
            };

            try
            {
                var item = _context.MaterialStoreExpGoodsHeaders.FirstOrDefault(x => x.ExpCode == obj.ExpCode);
                if (item != null)
                {
                    item.ExpCode       = obj.ExpCode;
                    item.SupplierId    = obj.SupplierId;
                    item.UserId        = obj.UserId;
                    item.Total         = obj.Total;
                    item.TotalPayment  = obj.TotalPayment;
                    item.Vat           = obj.Vat;
                    item.TotalPayed    = obj.TotalPayed;
                    item.ShipperId     = obj.ShipperId;
                    item.StoreId       = obj.StoreId;
                    item.TimeImpCreate = !string.IsNullOrEmpty(obj.TimeImpCreate) ? DateTime.ParseExact(obj.TimeImpCreate, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                    item.InsurantTime  = !string.IsNullOrEmpty(obj.InsurantTime) ? DateTime.ParseExact(obj.InsurantTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                    item.Debt          = obj.Debt;
                    item.Note          = obj.Note;
                    _context.MaterialStoreExpGoodsHeaders.Update(item);
                    _context.SaveChanges();
                    msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_UPDATE_SUCCESS"), CommonUtil.ResourceValue("MES_TITLE_INFORMATION_EXPSTORE"));
                }
                else
                {
                    msg.Error = true;
                    msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_EXITS"), CommonUtil.ResourceValue("MES_TITLE_INFORMATION_EXPSTORE"));
                }
            }
            catch (Exception ex)
            {
                msg.Error  = true;
                msg.Title  = String.Format(CommonUtil.ResourceValue("COM_MSG_UPDATE_FAILED"), CommonUtil.ResourceValue("MES_TITLE_INFORMATION_EXPSTORE"));
                msg.Object = ex;
            }
            return(Json(msg));
        }