public ActionResult SearchRules(TransactionRuleVM tranRule)
        {
            string validMsg = string.Empty;

            Helpers.UIDropDownRepo uiDDLRepo = new Helpers.UIDropDownRepo(_ddlRepo);
            tranRule.IsPostBack = "TRUE";
            if (ValidateSearch(tranRule, out validMsg))
            {
                //Need to change as it will also store the search result and the memory usage will be high
                TempData["RuleSearchCriteria"] = tranRule;

                tranRule.SearchedResult = new List <TransactionRuleVM>();

                this.AddSearchResult(ref tranRule);
                //tranRule.IsPostBack = "TRUE";
            }
            else
            {
                tranRule.ErrorMsg = validMsg;
            }

            tranRule.TransactionFrequencies = uiDDLRepo.getTransactionFrequencies();
            tranRule.Users              = uiDDLRepo.getUserDropDown();
            tranRule.Standards          = uiDDLRepo.getStandardDropDown();
            tranRule.Sections           = uiDDLRepo.getSectionDropDown();
            tranRule.ClassTypes         = uiDDLRepo.getClassTypeDropDown();
            tranRule.TransactionMasters = new SelectList(_ddlRepo.GetTransactionMasters(tranRule.SelectedFrequency), "TranMasterId", "TransactionName");

            return(View(tranRule));
        }
        public ActionResult SearchRules()
        {
            Helpers.UIDropDownRepo uiDDLRepo = new Helpers.UIDropDownRepo(_ddlRepo);

            TransactionRuleVM tranRule = new TransactionRuleVM();

            tranRule.TransactionMasters = new SelectList(new List <TransactionMasterDTO>(), "TranMasterId", "TransactionName");

            tranRule.IsPostBack = "FALSE";

            if (TempData.Peek("RuleSearchCriteria") != null)
            {
                tranRule = (TransactionRuleVM)TempData.Peek("RuleSearchCriteria");
                this.AddSearchResult(ref tranRule);
                tranRule.TransactionMasters = new SelectList(_ddlRepo.GetTransactionMasters(tranRule.SelectedFrequency), "TranMasterId", "TransactionName");

                tranRule.IsPostBack = "TRUE";
            }
            else
            {
                tranRule.SearchedResult = new List <TransactionRuleVM>();
            }

            tranRule.TransactionFrequencies = uiDDLRepo.getTransactionFrequencies();
            tranRule.Users      = uiDDLRepo.getUserDropDown();
            tranRule.Standards  = uiDDLRepo.getStandardDropDown();
            tranRule.Sections   = uiDDLRepo.getSectionDropDown();
            tranRule.ClassTypes = uiDDLRepo.getClassTypeDropDown();



            tranRule.SuccessMsg = "";
            tranRule.ErrorMsg   = "";
            return(View(tranRule));
        }
        public ActionResult TransactionRule(TransactionRuleVM trRuleVM)
        {
            Helpers.UIDropDownRepo uiDDLRepo = new Helpers.UIDropDownRepo(_ddlRepo);
            string message = string.Empty;
            string diffTo  = string.Empty;

            if (Validate(trRuleVM, out message, out diffTo))
            {
                //string diffTo = _trnsMaster.GetIsDifferentTo(trRuleVM.TranMaster.TranMasterId);

                if (!_trRule.IsDuplicate(trRuleVM.TranMaster.TranMasterId, trRuleVM.Standard == null?-1: trRuleVM.Standard.StandardId, trRuleVM.Section == null?-1: trRuleVM.Section.SectionId, trRuleVM.ClassType == null?-1: trRuleVM.ClassType.ClassTypeId, trRuleVM.UserDTO == null?-1: trRuleVM.UserDTO.UserMasterId, diffTo, trRuleVM.MODE, trRuleVM.TranRuleId))
                {
                    if (string.Equals(trRuleVM.MODE, "EDIT"))
                    {
                        _trRule.Update(trRuleVM);
                        return(RedirectToAction("SearchRules"));
                    }
                    _trRule.Insert(trRuleVM);
                    ModelState.Clear();

                    trRuleVM.MODE   = "ADD";
                    trRuleVM.Active = true;

                    trRuleVM.SuccessMsg = "Rule added successfully.";
                    trRuleVM.ErrorMsg   = string.Empty;
                }
                else
                {
                    trRuleVM.ErrorMsg   = "Rule is not unique for this transaction name.";
                    trRuleVM.SuccessMsg = string.Empty;
                }
            }
            else
            {
                trRuleVM.ErrorMsg   = message;
                trRuleVM.SuccessMsg = string.Empty;
            }
            trRuleVM.TransactionFrequencies = uiDDLRepo.getTransactionFrequencies();
            trRuleVM.Users                   = uiDDLRepo.getUserDropDown();
            trRuleVM.Standards               = uiDDLRepo.getStandardDropDown();
            trRuleVM.Sections                = uiDDLRepo.getSectionDropDown();
            trRuleVM.PenaltyCalcIn           = uiDDLRepo.getCalcType();
            trRuleVM.ClassTypes              = uiDDLRepo.getClassTypeDropDown();
            trRuleVM.PenaltyTransactionTypes = uiDDLRepo.getTransactionTypes();
            trRuleVM.TransactionMasters      = uiDDLRepo.getTransactionMasters();
            trRuleVM.PenaltyTransactionRules = uiDDLRepo.getTransactionRules();
            trRuleVM.IsPostBack              = "TRUE";


            return(RedirectToAction("SearchRules"));
        }
        public ActionResult TransactionRule(string mode, int?id)
        {
            Helpers.UIDropDownRepo uiDDLRepo = new Helpers.UIDropDownRepo(_ddlRepo);
            TransactionRuleVM      trRuleVM  = new TransactionRuleVM();

            trRuleVM.IsPostBack = "FALSE";
            if (string.Equals(mode, "EDIT", StringComparison.OrdinalIgnoreCase))
            {
                StatusDTO <TransactionRuleDTO> trRule = _trRule.Select(id.Value);
                if (trRule != null)
                {
                    trRuleVM.Active                 = trRule.ReturnObj.Active;
                    trRuleVM.ActualAmount           = trRule.ReturnObj.ActualAmount;
                    trRuleVM.ClassType              = trRule.ReturnObj.ClassType;
                    trRuleVM.DueDateIncreasesBy     = trRule.ReturnObj.DueDateIncreasesBy;
                    trRuleVM.FirstDueAfterDays      = trRule.ReturnObj.FirstDueAfterDays;
                    trRuleVM.IsdifferentTo          = trRule.ReturnObj.IsdifferentTo;
                    trRuleVM.PenaltyAmount          = trRule.ReturnObj.PenaltyAmount;
                    trRuleVM.PenaltyCalculatedIn    = trRule.ReturnObj.PenaltyCalculatedIn;
                    trRuleVM.PenaltyTransactionRule = trRule.ReturnObj.PenaltyTransactionRule;
                    trRuleVM.PenaltyTransactionType = trRule.ReturnObj.PenaltyTransactionType;
                    trRuleVM.RuleName               = trRule.ReturnObj.RuleName;
                    trRuleVM.Section                = trRule.ReturnObj.Section;
                    trRuleVM.Standard               = trRule.ReturnObj.Standard;
                    trRuleVM.TranMaster             = trRule.ReturnObj.TranMaster;
                    trRuleVM.TranRuleId             = trRule.ReturnObj.TranRuleId;
                    trRuleVM.UserDTO                = trRule.ReturnObj.UserDTO;

                    trRuleVM.MODE = "EDIT";

                    if (trRuleVM.TranMaster != null)
                    {
                        trRuleVM.SelectedFrequency = _trnsMaster.GetFreq(trRuleVM.TranMaster.TranMasterId);
                    }

                    trRuleVM.TransactionMasters = uiDDLRepo.getTransactionMasters(trRuleVM.SelectedFrequency);
                }
                else
                {
                    trRuleVM.TransactionMasters = new SelectList(new List <TransactionMasterDTO>(), "TranMasterId", "TransactionName");

                    if (TempData.Peek("RuleSearchCriteria") != null)
                    {
                        trRuleVM = (TransactionRuleVM)TempData.Peek("RuleSearchCriteria");
                        trRuleVM.TransactionMasters = new SelectList(_ddlRepo.GetTransactionMasters(trRuleVM.SelectedFrequency), "TranMasterId", "TransactionName");
                        trRuleVM.IsPostBack         = "TRUE";
                    }

                    trRuleVM.MODE   = "ADD";
                    trRuleVM.Active = true;
                }
            }
            else
            {
                trRuleVM.TransactionMasters = new SelectList(new List <TransactionMasterDTO>(), "TranMasterId", "TransactionName");

                if (TempData.Peek("RuleSearchCriteria") != null)
                {
                    trRuleVM = (TransactionRuleVM)TempData.Peek("RuleSearchCriteria");
                    trRuleVM.TransactionMasters = new SelectList(_ddlRepo.GetTransactionMasters(trRuleVM.SelectedFrequency), "TranMasterId", "TransactionName");
                    trRuleVM.IsPostBack         = "TRUE";
                }

                trRuleVM.MODE   = "ADD";
                trRuleVM.Active = true;
            }
            trRuleVM.TransactionFrequencies = uiDDLRepo.getTransactionFrequencies();
            trRuleVM.Users                   = uiDDLRepo.getUserDropDown();
            trRuleVM.Standards               = uiDDLRepo.getStandardDropDown();
            trRuleVM.Sections                = uiDDLRepo.getSectionDropDown();
            trRuleVM.PenaltyCalcIn           = uiDDLRepo.getCalcType();
            trRuleVM.ClassTypes              = uiDDLRepo.getClassTypeDropDown();
            trRuleVM.PenaltyTransactionTypes = uiDDLRepo.getTransactionTypes();

            trRuleVM.PenaltyTransactionRules = uiDDLRepo.getTransactionRules();
            trRuleVM.ErrorMsg   = string.Empty;
            trRuleVM.SuccessMsg = string.Empty;

            return(View(trRuleVM));
        }