public ResponseModel GetOrderandCustomerDetailByTicketID(int ticketID)
        {
            List <CustomOrderwithCustomerDetails> objorderMaster = new List <CustomOrderwithCustomerDetails>();
            StoreClaimCaller storeClaimCaller = new StoreClaimCaller();
            ResponseModel    objResponseModel = new ResponseModel();
            int    statusCode    = 0;
            string statusMessage = "";

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

                objorderMaster = storeClaimCaller.GetOrderDetailByticketID(new StoreClaimService(_connectionSting), ticketID, authenticate.TenantId);
                statusCode     =
                    objorderMaster.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 = objorderMaster;
            }
            catch (Exception)
            {
                throw;
            }

            return(objResponseModel);
        }
        public ResponseModel ClaimAssignDropdown(int assignID)
        {
            List <CustomStoreUserList> objUserList = new List <CustomStoreUserList>();
            ResponseModel objResponseModel         = new ResponseModel();
            int           statusCode    = 0;
            string        statusMessage = "";

            try
            {
                StoreClaimCaller storeClaimCaller = new StoreClaimCaller();

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

                objUserList = storeClaimCaller.UserList(new StoreClaimService(_connectionSting), assignID, authenticate.TenantId);
                statusCode  =
                    objUserList.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 = objUserList;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
        public ResponseModel IsClaimApprove(int claimID, double finalClaimAsked, bool IsApprove)
        {
            StoreClaimCaller storeClaimCaller = new StoreClaimCaller();
            ResponseModel    objResponseModel = new ResponseModel();
            int    statusCode    = 0;
            string statusMessage = "";

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

                int result = storeClaimCaller.ClaimApprove(new StoreClaimService(_connectionSting), claimID, finalClaimAsked, IsApprove, authenticate.UserMasterID, authenticate.TenantId);
                statusCode =
                    result == 0 ?
                    (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success;
                statusMessage               = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);
                objResponseModel.Status     = true;
                objResponseModel.StatusCode = statusCode;
                objResponseModel.Message    = statusMessage;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
        public ResponseModel GetClaimCommentForApprovel(int claimID)
        {
            List <CommentByApprovel> objClaimComment  = new List <CommentByApprovel>();
            StoreClaimCaller         storeClaimCaller = new StoreClaimCaller();
            ResponseModel            objResponseModel = new ResponseModel();
            int    statusCode    = 0;
            string statusMessage = "";

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate    = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));
                objClaimComment = storeClaimCaller.GetClaimCommentForApprovel(new StoreClaimService(_connectionSting), claimID);
                statusCode      =
                    objClaimComment.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 = objClaimComment;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
        public ResponseModel GetClaimByID(int ClaimID)
        {
            CustomClaimByID  objClaimMaster   = new CustomClaimByID();
            StoreClaimCaller storeClaimCaller = new StoreClaimCaller();
            ResponseModel    objResponseModel = new ResponseModel();
            int    statusCode    = 0;
            string statusMessage = "";

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));
                string url = configuration.GetValue <string>("APIURL") + _ClaimProductImage;
                objClaimMaster = storeClaimCaller.GetClaimByID(new StoreClaimService(_connectionSting), ClaimID, authenticate.TenantId, authenticate.UserMasterID, url);
                statusCode     =
                    objClaimMaster == null ?
                    (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 = objClaimMaster;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
        public ResponseModel AddStoreClaimComment(int claimID, string comment, int oldAssignID, int newAssignID, bool iSTicketingComment)
        {
            StoreClaimCaller storeClaimCaller = new StoreClaimCaller();
            ResponseModel    objResponseModel = new ResponseModel();
            int    statusCode    = 0;
            string statusMessage = "";

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

                int result = storeClaimCaller.AddClaimComment(new StoreClaimService(_connectionSting), claimID, comment, authenticate.UserMasterID, oldAssignID, newAssignID, iSTicketingComment);
                statusCode =
                    result == 0 ?
                    (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success;
                statusMessage               = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);
                objResponseModel.Status     = true;
                objResponseModel.StatusCode = statusCode;
                objResponseModel.Message    = statusMessage;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
        public ResponseModel RaiseClaim(IFormFile File)
        {
            StoreClaimMaster storeClaimMaster = new StoreClaimMaster();
            OrderMaster      orderDetails     = new OrderMaster();
            List <OrderItem> OrderItemDetails = new List <OrderItem>();
            var    files          = Request.Form.Files;
            string timeStamp      = DateTime.Now.ToString("ddmmyyyyhhssfff");
            string fileName       = "";
            string finalAttchment = "";
            string ImagePath      = string.Empty;

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

            storeClaimMaster = JsonConvert.DeserializeObject <StoreClaimMaster>(Keys["storeClaimMaster"]);
            // get order details from form
            orderDetails     = JsonConvert.DeserializeObject <OrderMaster>(Keys["orderDetails"]);
            OrderItemDetails = JsonConvert.DeserializeObject <List <OrderItem> >(Keys["orderItemDetails"]);

            //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 = rootPath + _ClaimProductImage;
            string Folderpath = Directory.GetCurrentDirectory();

            string[] filesName = finalAttchment.Split(",");


            ImagePath = Path.Combine(Folderpath, _ClaimProductImage);

            if (!Directory.Exists(ImagePath))
            {
                Directory.CreateDirectory(ImagePath);
            }

            ResponseModel objResponseModel = new ResponseModel();
            int           statusCode       = 0;
            string        statusMessage    = "";

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

                #region check orderdetails and item details

                if (orderDetails != null)
                {
                    if (orderDetails.OrderMasterID.Equals(0))
                    {
                        string      OrderNumber    = string.Empty;
                        string      OrderItemsIds  = string.Empty;
                        OrderMaster objorderMaster = null;

                        OrderCaller ordercaller = new OrderCaller();
                        //call insert order
                        orderDetails.CreatedBy = authenticate.UserMasterID;
                        OrderNumber            = ordercaller.addOrder(new OrderService(_connectionSting), orderDetails, authenticate.TenantId);
                        if (!string.IsNullOrEmpty(OrderNumber))
                        {
                            objorderMaster = ordercaller.getOrderDetailsByNumber(new OrderService(_connectionSting), OrderNumber, authenticate.TenantId);


                            if (objorderMaster != null)
                            {
                                if (OrderItemDetails != null)
                                {
                                    foreach (var item in OrderItemDetails)
                                    {
                                        item.OrderMasterID = objorderMaster.OrderMasterID;
                                        item.InvoiceDate   = orderDetails.InvoiceDate;
                                    }

                                    OrderItemsIds = ordercaller.AddOrderItem(new OrderService(_connectionSting), OrderItemDetails, authenticate.TenantId, authenticate.UserMasterID);
                                }
                                else
                                {
                                    OrderItemsIds = Convert.ToString(objorderMaster.OrderMasterID) + "|0|1";
                                    //OrderItemsIds = Convert.ToString(objorderMaster.OrderMasterID) + "|1";
                                }
                            }

                            storeClaimMaster.OrderMasterID = objorderMaster.OrderMasterID;
                            storeClaimMaster.OrderItemID   = OrderItemsIds;
                        }
                    }
                }
                #endregion

                StoreClaimCaller storeClaimCaller = new StoreClaimCaller();
                storeClaimMaster.TenantID  = authenticate.TenantId;
                storeClaimMaster.CreatedBy = authenticate.UserMasterID;
                int result = storeClaimCaller.InsertRaiseClaim(new StoreClaimService(_connectionSting), storeClaimMaster, finalAttchment);
                if (result > 0)
                {
                    if (files.Count > 0)
                    {
                        //string[] filesName = finalAttchment.Split(",");
                        for (int i = 0; i < files.Count; i++)
                        {
                            try
                            {
                                using (var ms = new MemoryStream())
                                {
                                    files[i].CopyTo(ms);
                                    var          fileBytes = ms.ToArray();
                                    MemoryStream msfile    = new MemoryStream(fileBytes);
                                    FileStream   docFile   = new FileStream(Path.Combine(ImagePath, filesName[i]), FileMode.Create, FileAccess.Write);
                                    msfile.WriteTo(docFile);
                                    docFile.Close();
                                    ms.Close();
                                    msfile.Close();
                                    string s = Convert.ToBase64String(fileBytes);
                                    byte[] a = Convert.FromBase64String(s);
                                    // act on the Base64 data
                                }
                                //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();
                                //    string s = Convert.ToBase64String(fileBytes);
                                //    byte[] a = Convert.FromBase64String(s);
                                //    // act on the Base64 data

                                //}
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                        }
                    }
                }
                statusCode =
                    result == 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 = result;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }