public void Add(St_CompanyTransactionKindSymbolSerial ObjSave)
 {
     _context.St_CompanyTransactionKindSymbolSerials.Add(ObjSave);
 }
        public JsonResult UpdateSt_CompanyTransactionKind(St_CompanyTransactionKind ObjUpdate)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);
                ObjUpdate.InsDateTime = DateTime.Now;
                ObjUpdate.InsUserID   = userId;
                ObjUpdate.CompanyID   = UserInfo.fCompanyId;

                if (!ModelState.IsValid)
                {
                    string Err    = " ";
                    var    errors = ModelState.Values.SelectMany(v => v.Errors);
                    foreach (ModelError error in errors)
                    {
                        Err = Err + error.ErrorMessage + " * ";
                    }
                    Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + Err;
                    Msg.Code = 0;
                    return(Json(Msg, JsonRequestBehavior.AllowGet));
                }
                if (ObjUpdate.SymbolSerial)
                {
                    var Obj         = new St_CompanyTransactionKindSymbolSerial();
                    var CheckIfSave = _unitOfWork.St_CompanyTransactionKindSymbolSerial.CheckIfSave(ObjUpdate.CompanyID, ObjUpdate.St_CompanyTransactionKindID);
                    if (CheckIfSave == null)
                    {
                        _unitOfWork.St_CompanyTransactionKindSymbolSerial.Delete(ObjUpdate.CompanyID, ObjUpdate.St_CompanyTransactionKindID);
                        _unitOfWork.Complete();
                        Obj.CompanyID = ObjUpdate.CompanyID;
                        Obj.StockCode = ObjUpdate.StockCode;
                        Obj.St_CompanyTransactionKindID = ObjUpdate.St_CompanyTransactionKindID;
                        Obj.LastSerial = 0;
                        _unitOfWork.St_CompanyTransactionKindSymbolSerial.Add(Obj);
                        _unitOfWork.Complete();
                    }
                }
                else
                {
                    var Obj         = new St_CompanyTransactionKindSymbolSerial();
                    var CheckIfSave = _unitOfWork.St_CompanyTransactionKindSymbolSerial.CheckIfSave(ObjUpdate.CompanyID, ObjUpdate.St_CompanyTransactionKindID);
                    if (CheckIfSave != null)
                    {
                        _unitOfWork.St_CompanyTransactionKindSymbolSerial.Delete(ObjUpdate.CompanyID, ObjUpdate.St_CompanyTransactionKindID);
                        _unitOfWork.Complete();
                    }
                }
                _unitOfWork.St_CompanyTransactionKind.Update(ObjUpdate);
                _unitOfWork.Complete();

                Msg.Code = 1;
                Msg.Msg  = Resources.Resource.UpdatedSuccessfully;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString();
                Msg.Code = 0;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
        }