public ResponseModel ModifyStoreAlert([FromBody] AlertUpdateModel alertModel)
        {
            int           updateCount      = 0;
            ResponseModel objResponseModel = new ResponseModel();
            int           statusCode       = 0;
            string        statusMessage    = "";

            try
            {
                ////Get token (Double encrypted) and get the tenant id
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));

                AlertCaller newAlert = new AlertCaller();
                updateCount = newAlert.UpdateStoreAlert(new StoreAlertService(_connectioSting), authenticate.TenantId, authenticate.UserMasterID, alertModel);

                statusCode =
                    updateCount == 0 ?
                    (int)EnumMaster.StatusCode.InternalServiceNotWorking : (int)EnumMaster.StatusCode.Success;

                statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);

                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = updateCount;
            }
            catch (Exception)
            {
                throw;
            }

            return(objResponseModel);
        }
        public ResponseModel BindStoreAlerts()
        {
            ResponseModel    objResponseModel = new ResponseModel();
            List <AlertList> objAlertList     = new List <AlertList>();
            int    statusCode    = 0;
            string statusMessage = "";

            try
            {
                //Get token (Double encrypted) and get the tenant id
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));

                AlertCaller newAlert = new AlertCaller();

                objAlertList = newAlert.BindStoreAlerts(new StoreAlertService(_connectioSting), authenticate.TenantId);
                statusCode   = objAlertList.Count == 0 ? (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success;

                statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);

                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = objAlertList;
            }
            catch (Exception)
            {
                throw;
            }

            return(objResponseModel);
        }
        public ResponseModel ValidateStoreAlertNameExist(int alertTypeId)
        {
            string        resultMessage    = "";
            ResponseModel objResponseModel = new ResponseModel();
            int           statusCode       = 0;
            string        statusMessage    = "";

            try
            {
                ////Get token (Double encrypted) and get the tenant id
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));

                AlertCaller newAlert = new AlertCaller();

                resultMessage = newAlert.ValidateStoreAlertNameExist(new StoreAlertService(_connectioSting), alertTypeId, authenticate.TenantId);

                statusCode =
                    string.IsNullOrEmpty(resultMessage) ?
                    (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success;

                statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);

                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = resultMessage;
            }
            catch (Exception)
            {
                throw;
            }

            return(objResponseModel);
        }
        public ResponseModel BulkUploadStoreAlert()
        {
            AlertCaller   newAlert         = new AlertCaller();
            ResponseModel objResponseModel = new ResponseModel();
            int           statusCode       = 0;
            string        statusMessage    = "";
            string        fileName         = "";
            string        finalAttchment   = "";
            string        timeStamp        = DateTime.Now.ToString("ddmmyyyyhhssfff");
            DataSet       dataSetCSV       = new DataSet();

            string[] filesName = null;


            try
            {
                var files = Request.Form.Files;

                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));

                #region Read from Form

                if (files.Count > 0)
                {
                    for (int i = 0; i < files.Count; i++)
                    {
                        fileName += files[i].FileName.Replace(".", "_" + authenticate.UserMasterID + "_" + timeStamp + ".") + ",";
                    }
                    finalAttchment = fileName.TrimEnd(',');
                }

                var exePath = Path.GetDirectoryName(System.Reflection
                                                    .Assembly.GetExecutingAssembly().CodeBase);
                Regex  appPathMatcher = new Regex(@"(?<!fil)[A-Za-z]:\\+[\S\s]*?(?=\\+bin)");
                var    appRoot        = appPathMatcher.Match(exePath).Value;
                string folderpath     = appRoot + "\\" + "BulkUpload" + "\\" + "Alert";


                if (files.Count > 0)
                {
                    filesName = finalAttchment.Split(",");
                    for (int i = 0; i < files.Count; i++)
                    {
                        using (var ms = new MemoryStream())
                        {
                            files[i].CopyTo(ms);
                            var          fileBytes = ms.ToArray();
                            MemoryStream msfile    = new MemoryStream(fileBytes);
                            FileStream   docFile   = new FileStream(folderpath + "\\" + filesName[i], FileMode.Create, FileAccess.Write);
                            msfile.WriteTo(docFile);
                            docFile.Close();
                            ms.Close();
                            msfile.Close();
                        }
                    }
                }

                dataSetCSV = CommonService.csvToDataSet(folderpath + "\\" + filesName[0]);

                #endregion

                int result = newAlert.BulkUploadStoreAlert(new StoreAlertService(_connectioSting),
                                                           authenticate.TenantId, authenticate.UserMasterID, dataSetCSV);

                statusCode                    = result > 0 ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound;
                statusMessage                 = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);
                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = result;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }