예제 #1
0
        public async Task <VmIndustryItem> GetIndustryById(int Id)
        {
            var dbPageResult = await repo.Get(Id);

            if (dbPageResult == null)
            {
                return(new VmIndustryItem());
            }

            var resultObj = new VmIndustryItem();

            Copy <Industry, VmIndustryItem>(dbPageResult, resultObj);

            return(resultObj);
        }
예제 #2
0
        public IActionResult Custs(string id)
        {
            var defaults = new PageModel();

            defaults.Selects.Add("cities", new List <SelectItem>(_cityRepo.Get().Result.Select(x => new SelectItem {
                ID = x.ID, Name = x.Name
            }).ToList()));
            defaults.Selects.Add("mainIndustries", new List <SelectItem>(_mainIndustryRepo.Get().Result.Select(x => new SelectItem {
                ID = x.ID, Name = x.Name
            }).ToList()));
            defaults.Selects.Add("industries", new List <SelectItem>(_industryRepo.Get().Result.Select(x => new SelectItem {
                ID = x.ID, Name = x.Name, Extra = x.MainIndustryID
            }).ToList()));
            if (id == null)
            {
                return(View("Custs", defaults));
            }
            else
            {
                var newID = Int32.Parse(id);
                defaults.Item = newID;
                defaults.Selects.Add("positions", new List <SelectItem>(_positionRepo.Get().Result.Select(x => new SelectItem
                {
                    ID = x.ID, Name = x.Name
                }).ToList()));

                defaults.Selects.Add("contacts", new List <SelectItem>(_contactRepo.GetByCustID(newID).Result.Select(x => new SelectItem
                {
                    ID = x.ID, Name = x.Name
                }).ToList()));

                defaults.Selects.Add("users", new List <SelectItem>(_userRepo.Get().Result.Select(x => new SelectItem
                {
                    ID = x.ID, Name = x.Username
                }).ToList()));

                defaults.Selects.Add("types", new List <SelectItem>(Enum.GetValues(typeof(Types)).Cast <Types>()
                                                                    .Select(x => new SelectItem {
                    ID = (int)x, Name = x.ToString()
                })).ToList());

                return(View("Cust", defaults));
            }
        }