/// <summary>
        /// return json for server side paging
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="sortField"></param>
        /// <param name="sortDirection"></param>
        /// <param name="searchString"></param>
        /// <param name="startDateFrom"></param>
        /// <param name="startDateTo"></param>
        /// <returns></returns>
        public JsonResult GetTransactionsList(int pageIndex, int pageSize, string sortField, string sortDirection, string searchString, string startDateFrom, string startDateTo)
        {
            List<TransactionModel> transactionModels;
            using (JetstreamClient objMainServiceClient = new JetstreamClient())
            {
                List<TransactionModel> transactionList;
                transactionList = objMainServiceClient.GetInventoryTransaction(searchString, startDateFrom,
                     startDateTo);

                transactionList.ForEach(x =>
                {
                    x.Location = x.Latitude +
                                 (x.Longitude != null ? string.Format(":{0}", x.Longitude) : x.Longitude)
                                 + (x.Range != null ? string.Format(":{0}", x.Range) : x.Range);
                });

                SortingPagingInfo info = new SortingPagingInfo
                {
                    SortField = sortField,
                    SortDirection = sortDirection,
                };
                transactionModels = ApplySorting(transactionList, info).Skip(pageIndex * pageSize).Take(pageSize).ToList();
            }
            return Json(new { transactionModels }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult InventoryTransaction(TransactionSearchModel transactionSearchMl, SortingPagingInfo info, string command)
        {
            StringBuilder objStringBuilderError = new StringBuilder();
            try
            {
                if (Session["UserName"] != null)
                {
                    if (!string.IsNullOrEmpty(command) && command.Equals(JetstreamResource.SearchCommand) && !CheckDate(transactionSearchMl.StartDateFrom))
                    {
                        transactionSearchMl.TransactionModels = null;
                        Warning(JetstreamResource.FromDateValidation, true);
                        ViewBag.SortingPagingInfo = info;
                        return View("InventoryTransaction", transactionSearchMl);
                    }

                    if (!string.IsNullOrEmpty(command) && command.Equals(JetstreamResource.SearchCommand) && !CheckDate(transactionSearchMl.StartDateTo))
                    {
                        transactionSearchMl.TransactionModels = null;
                        Warning(JetstreamResource.ToDateValidation, true);
                        ViewBag.SortingPagingInfo = info;
                        return View("InventoryTransaction", transactionSearchMl);
                    }

                    DateTime? StartDateFrom = !string.IsNullOrEmpty(transactionSearchMl.StartDateFrom) ? Convert.ToDateTime(transactionSearchMl.StartDateFrom) : (DateTime?)null;
                    DateTime? StartDateTo = !string.IsNullOrEmpty(transactionSearchMl.StartDateTo) ? Convert.ToDateTime(transactionSearchMl.StartDateTo) : (DateTime?)null;

                    if (!string.IsNullOrEmpty(command) && command.Equals(JetstreamResource.SearchCommand) && StartDateFrom > StartDateTo)
                    {
                        transactionSearchMl.TransactionModels = null;
                        Warning(JetstreamResource.DateValidation, true);
                        ViewBag.SortingPagingInfo = info;
                        return View("InventoryTransaction", transactionSearchMl);
                    }

                    using (JetstreamClient objMainServiceClient = new JetstreamClient())
                    {
                        IEnumerable<TransactionModel> lstTransactionModel;
                        lstTransactionModel =
                            objMainServiceClient.GetInventoryTransaction(transactionSearchMl.SearchString,
                                transactionSearchMl.StartDateFrom, transactionSearchMl.StartDateTo);

                        lstTransactionModel.ToList().ForEach(x =>
                        {
                            x.Location = x.Latitude + (x.Longitude != null ? string.Format(":{0}", x.Longitude) : x.Longitude)
                                + (x.Range != null ? string.Format(":{0}", x.Range) : x.Range);
                        });
                        if (lstTransactionModel.Any())
                        {
                            transactionSearchMl.TransactionModels = ApplySorting(lstTransactionModel.ToList(), info).Take(Constants.PagingPageSize).ToList();
                        }
                    }
                    ViewBag.SortingPagingInfo = info;
                    return View("InventoryTransaction", transactionSearchMl);

                }
                else
                {
                    return RedirectToAction("UserLogin", "Login");
                }
            }
            catch (FaultException<ServiceData> fex)
            {
                objStringBuilderError.AppendLine("In method : InventoryTransaction(TransactionSearchModel transactionSearchMl, SortingPagingInfo info, string command) :: TransactionController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", fex.Detail.ErrorMessage, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, fex.Detail.ErrorDetails);

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
                return View("Error");
            }
            catch (Exception ex)
            {
                objStringBuilderError.AppendLine("In method : InventoryTransaction(TransactionSearchModel transactionSearchMl, SortingPagingInfo info, string command) :: TransactionController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", ex.Message, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, ex.ToString());

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
                return View("Error");
            }
        }
        /// <summary>
        /// Displays the view
        /// </summary>
        /// <returns></returns>
        public ActionResult InventoryTransaction()
        {
            StringBuilder objStringBuilderError = new StringBuilder();

            TransactionSearchModel transactionSearchMl = new TransactionSearchModel();
            try
            {
                if (Session["UserName"] != null)
                {
                    using (JetstreamClient objMainServiceClient = new JetstreamClient())
                    {
                        IEnumerable<TransactionModel> lstTransactionModel = objMainServiceClient.GetInventoryTransaction(transactionSearchMl.SearchString, transactionSearchMl.StartDateFrom, transactionSearchMl.StartDateTo);

                        lstTransactionModel.ToList().ForEach(x =>
                        {
                            x.Location = x.Latitude +
                                         (x.Longitude != null ? string.Format(":{0}", x.Longitude) : x.Longitude)
                                         + (x.Range != null ? string.Format(":{0}", x.Range) : x.Range);
                        });

                        if (lstTransactionModel.Any())
                        {
                            transactionSearchMl.TransactionModels = new List<TransactionModel>(lstTransactionModel);
                        }
                    }

                    SortingPagingInfo info = new SortingPagingInfo
                    {
                        SortField = Enums.TransactionSortField.StateDate.ToString(),
                        SortDirection = Constants.Ascending,
                    };
                    if (transactionSearchMl.TransactionModels != null)
                        transactionSearchMl.TransactionModels = ApplySorting(transactionSearchMl.TransactionModels, info).Take(Constants.PagingPageSize).ToList();
                    ViewBag.SortingPagingInfo = info;

                    transactionSearchMl.StartDateFrom = string.Empty;// DateTime.Now.ToShortDateString();
                    transactionSearchMl.StartDateTo = string.Empty; //DateTime.Now.ToShortDateString();
                    return View("InventoryTransaction", transactionSearchMl);
                }
                else
                {
                    return RedirectToAction("UserLogin", "Login");
                }
            }
            catch (FaultException<ServiceData> fex)
            {
                objStringBuilderError.AppendLine("In method : InventoryTransaction() :: TransactionController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", fex.Detail.ErrorMessage, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, fex.Detail.ErrorDetails);

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
                return View("Error");
            }
            catch (Exception ex)
            {
                objStringBuilderError.AppendLine("In method : InventoryTransaction() :: TransactionController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", ex.Message, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, ex.ToString());

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
                return View("Error");
            }
        }