public static IList <LookupViewModel> ConcatValuesForLookup(this string fields, IList <Dictionary <string, dynamic> > data, string delimiter, string id)
        {
            var keys = fields.Split(',').ToList <string>();
            IList <LookupViewModel> result = new List <LookupViewModel>();

            for (int i = 0; i < data.Count; i++)
            {
                var title = String.Empty;
                for (int j = 0; j < keys.Count; j++)
                {
                    if (j > 0)
                    {
                        title = title + delimiter;
                    }
                    title = title + data[i][keys[j]];
                }
                try {
                    var item = new LookupViewModel()
                    {
                        ID    = unchecked ((int)(data[i][id])),
                        Value = title
                    };
                    result.Add(item);
                } catch (Exception e) {
                    Console.Write(e);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public IActionResult Index(LookupViewModel vm, string buttonValue)
        {
            switch (buttonValue)
            {
            case "Save":
                if (ModelState.IsValid)
                {
                    vm.EditLookup.GroupId = vm.SelectedGroupId;
                    LookupRepo.SaveLookup(vm.EditLookup);
                    vm.EditLookup = new TimeCard.Domain.Lookup();
                    ModelState.Clear();
                }
                break;

            case "Delete":
                LookupRepo.DeleteLookup(vm.EditLookup.Id);
                break;

            default:
                vm.EditLookup = new TimeCard.Domain.Lookup();
                ModelState.Clear();
                break;
            }
            prepIndex(vm);
            return(View(vm));
        }
Ejemplo n.º 3
0
        public ActionResult LookupRate(string lookupEmail)
        {
            if (string.IsNullOrEmpty(lookupEmail))
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                using (InsuranceEntities db = new InsuranceEntities())
                {
                    var Users      = db.Users;
                    var FoundUsers = Users.Where(x => x.Email == lookupEmail).ToList();
                    if (FoundUsers.Count() < 1)
                    {
                        return(View("NoAccountError"));
                    }
                    else
                    {
                        var userInfo = new LookupViewModel();

                        User user = FoundUsers.FirstOrDefault();

                        var cars = from c in db.Cars
                                   where c.UserId == user.Id
                                   select c;

                        var listCars = new List <CarViewModel>();

                        foreach (Car car in cars)
                        {
                            var tempcar = new CarViewModel();
                            tempcar.Make      = car.Make;
                            tempcar.Model     = car.Model;
                            tempcar.Year      = car.Year;
                            tempcar.Rate      = db.Quotes.Where(x => x.Id == car.QuoteId).ToList().FirstOrDefault().Rate;
                            tempcar.IssueDate = db.Quotes.Where(x => x.Id == car.QuoteId).ToList().FirstOrDefault().IssueDate;
                            listCars.Add(tempcar);
                        }

                        //Calculate Points
                        var Tickets     = db.Tickets;
                        var userTickets = db.Tickets.Where(x => x.UserId == user.Id).ToList();
                        int points      = userTickets.Count(x => (DateTime.Now - x.IssueDate).Days <= 1095);

                        userInfo.FirstName = user.FirstName;
                        userInfo.LastName  = user.LastName;
                        userInfo.UserEmail = user.Email;
                        userInfo.NumCars   = cars.Count();
                        userInfo.Points    = points;
                        userInfo.Dui       = (user.DuiActive == 1) ? true : false;
                        userInfo.TotalRate = user.CompleteQuote;
                        userInfo.Cars      = listCars;

                        return(View(userInfo));
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public IActionResult Index()
        {
            var vm = new LookupViewModel {
                EditLookup = new TimeCard.Domain.Lookup()
            };

            prepIndex(vm);
            return(View(vm));
        }
Ejemplo n.º 5
0
 void prepIndex(LookupViewModel vm)
 {
     vm.LookupGroups = LookupRepo.GetGroups().Select(x => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
         Value = x.GroupId.ToString(), Text = x.Descr
     });
     if (vm.SelectedGroupId != 0)
     {
         vm.Lookups = LookupRepo.GetLookups(vm.SelectedGroupId);
     }
 }
Ejemplo n.º 6
0
        public static List <LookupViewModel> MapToLookupViewModel(List <City> cities)
        {
            var listViewModel = new List <LookupViewModel>();

            if (cities != null && cities.Count > 0)
            {
                foreach (City city in cities)
                {
                    var viewModel = new LookupViewModel();

                    viewModel.Id   = city.ID;
                    viewModel.Name = city.Name;

                    listViewModel.Add(viewModel);
                }
            }
            return(listViewModel);
        }
Ejemplo n.º 7
0
        public static List <LookupViewModel> MapToLookupViewModel(List <Language> languages)
        {
            var listViewModel = new List <LookupViewModel>();

            if (languages != null && languages.Count > 0)
            {
                foreach (Language language in languages)
                {
                    var viewModel = new LookupViewModel();

                    viewModel.Id   = language.ID;
                    viewModel.Name = language.LanguageName;

                    listViewModel.Add(viewModel);
                }
            }
            return(listViewModel);
        }
Ejemplo n.º 8
0
        public static List <LookupViewModel> MapToLookupViewModel(List <Category> categories)
        {
            var listViewModel = new List <LookupViewModel>();

            if (categories != null && categories.Count > 0)
            {
                foreach (Category category in categories)
                {
                    var viewModel = new LookupViewModel();

                    viewModel.Id   = category.ID;
                    viewModel.Name = category.Name;

                    listViewModel.Add(viewModel);
                }
            }
            return(listViewModel);
        }
Ejemplo n.º 9
0
        public ActionResult Read(LookupViewModel viewModel)
        {
            questStatus        status             = null;
            UserMessageModeler userMessageModeler = null;

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Log Operation
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = LogOperation();
            if (!questStatusDef.IsSuccess(status))
            {
                userMessageModeler = new UserMessageModeler(status);
                return(Json(userMessageModeler, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Authorize
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = Authorize(viewModel._ctx);
            if (!questStatusDef.IsSuccess(status))
            {
                userMessageModeler = new UserMessageModeler(status);
                return(Json(userMessageModeler, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Perform operation.
            *---------------------------------------------------------------------------------------------------------------------------------*/
            List <OptionValuePair> lookupOptionList = null;
            LookupModeler          lookupModeler    = new LookupModeler(this.Request, this.UserSession);

            status = lookupModeler.Read(viewModel, out lookupOptionList);
            if (!questStatusDef.IsSuccess(status))
            {
                userMessageModeler = new UserMessageModeler(status);
                return(Json(userMessageModeler, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Return result.
            *---------------------------------------------------------------------------------------------------------------------------------*/
            return(Json(lookupOptionList, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 10
0
        public LookupViewModel GetLookups()
        {
            LookupViewModel vm = new LookupViewModel();

            foreach (cCatItem item in catHandler.Categories)
            {
                vm.Categories.Add(item.CategoryType.ToString(), item.Items);
            }
            var riskGrid = new TFI.BusinessLogic.StaticMethods.cPortfolioRiskGrid();

            riskGrid.populateInitialCollectionValues();
            vm.PortRisks = riskGrid.PortRisks;
            vm.Services  = _lookupBL.GetLicenceService().Services;
            //vm.Countries = _lookupBL.GetCountries().Countries;
            //vm.Districts = _lookupBL.GetDistricts().Districts;
            //vm.Genders = _lookupBL.GetGenders().GenderList;
            vm.Currencies = _lookupBL.GetCurrencies().Currencies;
            return(vm);
        }
Ejemplo n.º 11
0
        public JsonResult Get_Lookup_Data_By_Id(string field_Value, string table_Name, string columns, string headerNames)

        {
            LookupViewModel LookupVM = new LookupViewModel();

            try

            {
                string[] cols;

                string[] headerNamesArr;

                cols = columns.Split(',');

                if (headerNames != null)
                {
                    headerNamesArr = headerNames.Split(',');

                    LookupVM.HeaderNames = headerNamesArr;
                }

                if (table_Name == "Country")
                {
                    if (field_Value != null)
                    {
                        LookupVM.Value = _autoLookupRepo.Get_Lookup_Data_Country(field_Value, table_Name, cols);
                    }
                }

                Logger.Debug("AutoCompleteLookup Controller Get_Lookup_Data_By_Id");
            }
            catch (Exception ex)
            {
                Logger.Error("AutoCompleteLookup Controller- Get_Lookup_Data_By_Id" + ex.Message);
            }

            return(Json(LookupVM.Value, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 12
0
        public PartialViewResult Load_Modal_Data(string table_Name, string columns, string headerNames, string editValue, string fieldValue, string fieldName, int currentPage)
        {
            LookupViewModel LookupVM = new LookupViewModel();

            string[] cols;

            string[] headerNamesArr;

            cols = columns.Split(',');

            if (headerNames != null)
            {
                headerNamesArr = headerNames.Split(',');

                LookupVM.HeaderNames = headerNamesArr;

                Logger.Debug("AutoCompleteLookup Controller Load_Modal_Data");
            }

            try
            {
                LookupVM.Pager.CurrentPage = currentPage;

                DataTable dt = _autoLookupRepo.Get_Lookup_Data(table_Name, cols, fieldValue, fieldName, 1);

                LookupVM.Pager = new PaginationInfo(LookupVM.PartialDt.Rows.Count, LookupVM.Pager.CurrentPage);

                LookupVM.PartialDt = dt.AsEnumerable().Skip((LookupVM.Pager.CurrentPage - 1) * LookupVM.Pager.PageSize).Take(LookupVM.Pager.PageSize).CopyToDataTable();

                LookupVM.EditLookupValue = editValue;
            }
            catch (Exception ex)
            {
                Logger.Error("AutoCompleteLookup Controller - Load_Modal_Data" + ex.Message);
            }

            return(PartialView("_Lookup", LookupVM));
        }
Ejemplo n.º 13
0
        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Read(LookupViewModel lookupViewModel, out List <OptionValuePair> lookupOptionList)
        {
            // Initialize
            questStatus status = null;

            lookupOptionList = null;


            // Create lookup request
            LookupRequest lookupRequest = new LookupRequest();

            lookupRequest.LookupId = new LookupId(lookupViewModel.Id);
            if (lookupViewModel.FilterItemId >= BaseId.VALID_ID)
            {
                lookupRequest.FilterItemId = new FilterItemId(lookupViewModel.FilterItemId);
            }

            // Get lookup options
            LookupId lookupId = new LookupId(lookupViewModel.Id);
            List <LookupArgument> lookupArgumentList = null;    // TODO
            LookupMgr             lookupMgr          = new LookupMgr(this.UserSession);

            status = lookupMgr.GetLookupOptions(lookupRequest, lookupArgumentList, out lookupOptionList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Insert default option
            status = AddDefaultOptions(lookupOptionList, "-1", "Select one ...");
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 14
0
        public static MvcHtmlString Lookup(this HtmlHelper htmlHelper, string lookupId,
                                           string label,
                                           string modelName,
                                           string dataBindingValue,
                                           int col    = 6,
                                           string url = "",
                                           bool populatedByChildren       = false,
                                           string hierarchyGroupName      = "",
                                           string urlToReadData           = "", string urlToGetLookupItem = "", bool isRequired = false, object htmlAttribute = null, int currentId = 0, object dataSource = null, int heightLookup = 250,
                                           string customParams            = "",
                                           string angularLookupController = "",
                                           string isShow = "true",
                                           string addLookupPopupFunction  = "",
                                           string editLookupPopupFunction = "",
                                           string moreClass = "",
                                           bool showAddEdit = true,
                                           string enable    = "true")
        {
            var attribute = new RouteValueDictionary();

            if (htmlAttribute != null)
            {
                attribute = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttribute);
            }

            attribute.Add("id", lookupId);

            if (attribute.ContainsKey("style"))
            {
                if (!attribute["style"].ToString().Contains("width"))
                {
                    attribute["style"] = attribute["style"] + "width: 270px;";
                }
            }
            else
            {
                attribute.Add("style", "");
            }

            if (isRequired)
            {
                attribute["required"] = "required";
            }

            attribute["style"] = attribute["style"] + "display: none;";

            var model = new LookupViewModel
            {
                ID                      = lookupId,
                Label                   = label,
                ModelName               = modelName,
                UrlToReadData           = urlToReadData,
                UrlToGetLookupItem      = urlToGetLookupItem,
                CurrentId               = currentId,
                HtmlAttributes          = attribute,
                HierarchyGroupName      = hierarchyGroupName,
                PopulatedByChildren     = populatedByChildren,
                DataSource              = new List <object>(),
                HeightLookup            = heightLookup,
                DataBindingValue        = dataBindingValue,
                Required                = isRequired,
                Col                     = col,
                CustomParams            = customParams,
                AngularLookupController = angularLookupController,
                IsShow                  = isShow,
                AddLookupPopupFunction  = addLookupPopupFunction,
                EditLookupPopupFunction = editLookupPopupFunction,
                MoreClass               = moreClass,
                ShowAddEdit             = showAddEdit,
                Enable                  = enable
            };

            if (dataSource != null)
            {
                model.DataSource.Add(dataSource);
            }
            if (string.IsNullOrEmpty(url))
            {
                url = "~/Views/Shared/Lookup/_Lookup.cshtml";
            }
            return(htmlHelper.Partial(url, model));
        }
Ejemplo n.º 15
0
        public LookupPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new LookupViewModel();
        }