public async Task <IActionResult> AddZipCode(AddZipCodeReq Request)//long ZipCode, string AreaName, long CityID
        {
            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.AddZipCode(Request, user.Id);//Request.ZipCode, Request.AreaName, Request.CityID
                }
                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 async Task <IActionResult> DisableLimitRule(long LimitRuleMasterId)
        {
            BizResponseClass Response = new BizResponseClass();

            try
            {
                ApplicationUser user = new ApplicationUser(); user.Id = 1;
                //ApplicationUser 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 = _communicationService.DisableLimitRule(LimitRuleMasterId);
                }
                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 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 Cities GetCity(long CityID)
 {
     try
     {
         Cities           cities = new Cities();
         BizResponseClass Resp   = new BizResponseClass();
         var IsExist             = _commonRepoCity.GetSingle(item => item.Id == CityID);
         if (IsExist != null)
         {
             cities.CityName = IsExist.CityName;
             cities.Status   = IsExist.Status;
             Resp.ErrorCode  = enErrorCode.Success;
             Resp.ReturnCode = enResponseCode.Success;
             Resp.ReturnMsg  = EnResponseMessage.FindRecored;
         }
         else
         {
             Resp.ErrorCode  = enErrorCode.NotFound;
             Resp.ReturnCode = enResponseCode.Fail;
             Resp.ReturnMsg  = EnResponseMessage.NotFound;
         }
         cities.BizResponseObj = Resp;
         return(cities);
     }
     catch (Exception ex)
     {
         HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex);
         throw;
     }
 }
 public BizResponseClass UpdateZipCode(AddZipCodeReq Request, long UserID)
 {
     try
     {
         BizResponseClass Resp = new BizResponseClass();
         var IsExist           = _commonRepoZipCode.GetSingle(item => item.Id == Request.ZipCodeID && item.Status == Convert.ToInt16(ServiceStatus.Active));
         if (IsExist != null)
         {
             IsExist.ZipCode     = Request.ZipCode;
             IsExist.ZipAreaName = Request.AreaName;
             IsExist.CityID      = Request.CityID;
             IsExist.Status      = Request.Status;
             IsExist.UpdatedBy   = UserID;
             IsExist.UpdatedDate = UTC_To_IST();
             _commonRepoZipCode.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;
     }
 }
Esempio n. 6
0
        public async Task <IActionResult> TradeRecon([FromBody] TradeReconRequest request)
        {
            BizResponseClass Response = new BizResponseClass();

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

                if (user == null)
                {
                    Response.ReturnCode = enResponseCode.Fail;
                    Response.ReturnMsg  = EnResponseMessage.StandardLoginfailed;
                    Response.ErrorCode  = enErrorCode.StandardLoginfailed;
                }
                if (request.TranNo == 0)
                {
                    Response.ReturnCode = enResponseCode.Fail;
                    Response.ReturnMsg  = EnResponseMessage.TradeRecon_InvalidTransactionNo;
                    Response.ErrorCode  = enErrorCode.TradeRecon_InvalidTransactionNo;
                }
                if (request.ActionType != enTradeReconActionType.Cancel)
                {
                    Response.ReturnCode = enResponseCode.Fail;
                    Response.ReturnMsg  = EnResponseMessage.TradeRecon_InvalidActionType;
                    Response.ErrorCode  = enErrorCode.TradeRecon_InvalidActionType;
                }
                else
                {
                    var UserId = user.Id;
                    Response = _backOfficeService.TradeRecon(request.TranNo, request.ActionMessage, UserId);
                }

                return(Ok(Response));
            }
            catch (Exception ex)
            {
                // HelperForLog.WriteErrorLog(_basePage.UTC_To_IST(), this.ControllerContext.RouteData.Values["action"].ToString(), this.GetType().Name, ex.ToString());
                //return BadRequest();
                return(BadRequest(new BizResponseClass {
                    ReturnCode = enResponseCode.InternalError, ReturnMsg = ex.ToString(), ErrorCode = enErrorCode.Status500InternalServerError
                }));
            }
        }
        public async Task <IActionResult> UpdateCityDetail(AddCityReq Request)
        {
            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 if (Request.CityID == null || Request.CityID == 0)
                {
                    Response.ReturnCode = enResponseCode.Fail;
                    Response.ReturnMsg  = EnResponseMessage.MasterConfig;
                    Response.ErrorCode  = enErrorCode.InvalidMasterID;
                }
                else
                {
                    var accessToken = await HttpContext.GetTokenAsync("access_token");

                    Response = _masterConfiguration.UpdateCity(Request, user.Id);
                }
                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
                }));
            }
        }
Esempio n. 8
0
        public BizResponseClass TradeRecon(long TranNo, string ActionMessage, long UserId)
        {
            BizResponseClass Response = new BizResponseClass();

            try
            {
                var transactionQueue = _transactionQueueRepository.GetById(TranNo);
                var tradeTranQueue   = _tradeTransactionRepository.GetSingle(x => x.TrnNo == TranNo);
                var tradeBuyRequest  = _tradeBuyRepository.GetSingle(x => x.TrnNo == TranNo);

                if (transactionQueue != null && transactionQueue != null && tradeBuyRequest != null)
                {
                    var datediff = _basePage.UTC_To_IST() - transactionQueue.TrnDate;
                    if (UserId != 1 && datediff.Days > 7)
                    {
                        //After 7 days of transaction you can not take action, Please contact admin
                        Response.ReturnCode = enResponseCode.Fail;
                        Response.ReturnMsg  = EnResponseMessage.TradeRecon_After7DaysTranDontTakeAction;
                        Response.ErrorCode  = enErrorCode.TradeRecon_After7DaysTranDontTakeAction;
                    }
                    else if (transactionQueue.Status != 4)
                    {
                        //Invalid Transaction Status For Trade Recon
                        Response.ReturnCode = enResponseCode.Fail;
                        Response.ReturnMsg  = EnResponseMessage.TradeRecon_InvalidTransactionStatus;
                        Response.ErrorCode  = enErrorCode.TradeRecon_InvalidTransactionStatus;
                    }
                    else if (tradeTranQueue.IsCancelled == 1)
                    {
                        //Transaction Cancellation request is already in processing.
                        Response.ReturnCode = enResponseCode.Fail;
                        Response.ReturnMsg  = EnResponseMessage.TradeRecon_CancelRequestAlreayInProcess;
                        Response.ErrorCode  = enErrorCode.TradeRecon_CancelRequestAlreayInProcess;
                    }
                    else if (tradeBuyRequest.IsProcessing == 1)
                    {
                        //Transaction Already in Process, Please try After Sometime
                        Response.ReturnCode = enResponseCode.Fail;
                        Response.ReturnMsg  = EnResponseMessage.TradeRecon_TransactionAlreadyInProcess;
                        Response.ErrorCode  = enErrorCode.TradeRecon_TransactionAlreadyInProcess;
                    }
                    else if (tradeBuyRequest.PendingQty == 0)
                    {
                        //Can not initiate Cancellation Request.Your order is fully executed
                        Response.ReturnCode = enResponseCode.Fail;
                        Response.ReturnMsg  = EnResponseMessage.TradeRecon_OrderIsFullyExecuted;
                        Response.ErrorCode  = enErrorCode.TradeRecon_OrderIsFullyExecuted;
                    }
                    else
                    {
                        var DeliveryQty = Math.Round((transactionQueue.Amount * tradeBuyRequest.PendingQty) / tradeBuyRequest.Qty, 8);

                        if (DeliveryQty == 0 || DeliveryQty < 0)
                        {
                            //Invalid Delivery Amount
                            Response.ReturnCode = enResponseCode.Fail;
                            Response.ReturnMsg  = EnResponseMessage.TradeRecon_InvalidDeliveryAmount;
                            Response.ErrorCode  = enErrorCode.TradeRecon_InvalidDeliveryAmount;
                        }
                        if (DeliveryQty > transactionQueue.Amount)
                        {
                            //Invalid Delivery Amount
                            Response.ReturnCode = enResponseCode.Fail;
                            Response.ReturnMsg  = EnResponseMessage.TradeRecon_InvalidDeliveryAmount;
                            Response.ErrorCode  = enErrorCode.TradeRecon_InvalidDeliveryAmount;
                        }
                        else
                        {
                            //Add record in Transaction Cancel Queue
                            var tradeCancelQueue = new TradeCancelQueue()
                            {
                                TrnNo            = TranNo,
                                DeliverServiceID = transactionQueue.ServiceID,
                                TrnDate          = _basePage.UTC_To_IST(),
                                PendingBuyQty    = tradeBuyRequest.PendingQty,
                                DeliverQty       = DeliveryQty,
                                Status           = 0,
                                StatusMsg        = "Cancel Order",
                                CreatedBy        = UserId,
                                CreatedDate      = _basePage.UTC_To_IST()
                            };

                            tradeCancelQueue = _tradeCancelQueueRepository.Add(tradeCancelQueue);

                            //Add record in PoolOrder
                            var poolOrder = new PoolOrder()
                            {
                                CreatedDate  = _basePage.UTC_To_IST(),
                                CreatedBy    = UserId,
                                TrnMode      = Convert.ToByte(transactionQueue.TrnMode),
                                PayMode      = Convert.ToInt16(enWebAPIRouteType.TradeServiceLocal),
                                ORemarks     = "Cancellation Initiated",
                                OrderAmt     = DeliveryQty,
                                OMemberID    = transactionQueue.MemberID,
                                DMemberID    = tradeBuyRequest.SellStockID,
                                DiscPer      = 0,
                                DiscRs       = 0,
                                Status       = Convert.ToInt16(enTransactionStatus.Initialize),//txn type status
                                UserWalletID = tradeTranQueue.OrderWalletID,
                                //UserWalletAccID = tradeTranQueue.OrderWalletID,
                                TrnNo       = TranNo,
                                CancelID    = tradeCancelQueue.Id,
                                DeliveryAmt = DeliveryQty,
                                DRemarks    = "Cancel Order",

                                //OrderDate = _basePage.UTC_To_IST(),
                                //TrnMode = Convert.ToByte(transactionQueue.TrnMode),
                                //OMemberID = transactionQueue.MemberID,
                                //PayMode = 2,
                                //OrderAmt = DeliveryQty,
                                //DiscPer = 0,
                                //DiscRs = 0,
                                //OBankID = 0,
                                //OBranchName = "",
                                //OAccountNo = "",
                                //OChequeNo = "",
                                //DMemberID = tradeBuyRequest.SellStockID,
                                //DBankID = 0,
                                //DAccountNo = "",
                                //Status = 0,
                                //ORemarks = "",
                                //AlertRec = 0,
                                //CashChargePer = 0,
                                //CashChargeRs = 0,
                                //WalletAmt = 0,
                                //PGId = 0,
                                //CouponNo = 0,
                                //IsChargeAccepted = false,
                                //WalletID = tradeTranQueue.OrderWalletID,
                                //CreatedBy = UserId,
                                //CreatedDate = _basePage.UTC_To_IST()
                            };

                            poolOrder = _poolOrderRepository.Add(poolOrder);

                            //Update TradeBuyRequest
                            tradeBuyRequest.UpdatedDate = _basePage.UTC_To_IST();
                            tradeBuyRequest.UpdatedBy   = UserId;
                            tradeBuyRequest.IsCancel    = 1;
                            _tradeBuyRepository.Update(tradeBuyRequest);

                            //Update TradeTransaction Queue
                            tradeTranQueue.UpdatedDate = _basePage.UTC_To_IST();
                            tradeTranQueue.UpdatedBy   = UserId;
                            tradeTranQueue.IsCancelled = 1;
                            tradeTranQueue.StatusMsg   = "Cancellation Initiated";
                            _tradeTransactionRepository.Update(tradeTranQueue);

                            //Update OrderID in TransactionCancel Queue
                            tradeCancelQueue.OrderID = poolOrder.Id;
                            _tradeCancelQueueRepository.Update(tradeCancelQueue);

                            var tradePoolMaster = _tradePoolMasterRepository.GetSingle(x => x.Id == tradeBuyRequest.SellStockID && x.IsSleepMode == 1);
                            if (tradePoolMaster != null)
                            {
                                tradePoolMaster.IsSleepMode = 0;
                                _tradePoolMasterRepository.Update(tradePoolMaster);
                            }

                            Response.ReturnCode = enResponseCode.Success;
                            Response.ReturnMsg  = EnResponseMessage.TradeRecon_CencelRequestSuccess;
                            Response.ErrorCode  = enErrorCode.TradeRecon_CencelRequestSuccess;
                        }
                    }
                }
                else
                {
                    Response.ReturnCode = enResponseCode.Fail;
                    Response.ReturnMsg  = EnResponseMessage.TradeRecon_InvalidTransactionNo;
                    Response.ErrorCode  = enErrorCode.TradeRecon_InvalidTransactionNo;
                }

                return(Response);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
                throw ex;
            }
        }