public BizResponseClass AddState(AddStateReq Request, long UserID)//string StateName, string StateCode, long CountryID, short Status
        {
            BizResponseClass Resp = new BizResponseClass();

            try
            {
                StateMaster obj = new StateMaster();
                obj.StateName   = Request.StateName;
                obj.StateCode   = Request.StateCode;
                obj.Status      = Request.Status;
                obj.CountryID   = Request.CountryID;
                obj.CreatedBy   = UserID;
                obj.CreatedDate = UTC_To_IST();
                _commonRepoState.Add(obj);
                Resp.ErrorCode  = enErrorCode.Success;
                Resp.ReturnCode = enResponseCode.Success;
                Resp.ReturnMsg  = EnResponseMessage.RecordAdded;
                return(Resp);
            }
            catch (Exception ex)
            {
                HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex);
                throw ex;
            }
        }
        public async Task <IActionResult> AddState(AddStateReq Request)//string StateName, string StateCode, long CountryID
        {
            BizResponseClass Response = new BizResponseClass();

            try
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                if (user == null)
                {
                    Response.ReturnCode = enResponseCode.Fail;
                    Response.ReturnMsg  = EnResponseMessage.StandardLoginfailed;
                    Response.ErrorCode  = enErrorCode.StandardLoginfailed;
                }
                else
                {
                    var accessToken = await HttpContext.GetTokenAsync("access_token");

                    Response = _masterConfiguration.AddState(Request, user.Id);//Request.StateName, Request.StateCode, Request.CountryID
                }
                var     respObj     = JsonConvert.SerializeObject(Response);
                dynamic respObjJson = JObject.Parse(respObj);
                return(Ok(respObjJson));
            }
            catch (Exception ex)
            {
                return(BadRequest(new BizResponseClass {
                    ReturnCode = enResponseCode.InternalError, ReturnMsg = ex.ToString(), ErrorCode = enErrorCode.Status500InternalServerError
                }));
            }
        }
 public BizResponseClass UpdateState(AddStateReq Request, long UserID)
 {
     try
     {
         BizResponseClass Resp = new BizResponseClass();
         var IsExist           = _commonRepoState.GetSingle(item => item.Id == Request.StateID && item.Status == Convert.ToInt16(ServiceStatus.Active));
         if (IsExist != null)
         {
             IsExist.StateName   = Request.StateName;
             IsExist.StateCode   = Request.StateCode;
             IsExist.CountryID   = Request.CountryID;
             IsExist.Status      = Request.Status;
             IsExist.UpdatedBy   = UserID;
             IsExist.UpdatedDate = UTC_To_IST();
             _commonRepoState.Update(IsExist);
             Resp.ErrorCode  = enErrorCode.Success;
             Resp.ReturnCode = enResponseCode.Success;
             Resp.ReturnMsg  = EnResponseMessage.RecordUpdated;
         }
         else
         {
             Resp.ErrorCode  = enErrorCode.NotFound;
             Resp.ReturnCode = enResponseCode.Fail;
             Resp.ReturnMsg  = EnResponseMessage.NotFound;
         }
         return(Resp);
     }
     catch (Exception ex)
     {
         HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex);
         throw;
     }
 }