예제 #1
0
        public async Task <IActionResult> AddCompanySection(long id)
        {
            var result = await _companyBusinessManager.GetCompany(id);

            if (result == null)
            {
                return(NotFound());
            }

            var companySections = await _companyBusinessManager.GetSections(id);

            var sections = await _sectionBusinessManager.GetSections();

            var exist = sections.Where(x => !companySections.Any(y => x.Id == y.SectionId)).ToList();

            var viewDataDictionary = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary())
            {
                { "SectionList", _mapper.Map <List <SectionViewModel> >(exist) }
            };

            if (exist.Count != 0)
            {
                var model = new CompanySectionViewModel()
                {
                    CompanyId = id
                };
                string html = _viewRenderService.RenderToStringAsync("_AddSectionPartial", model, viewDataDictionary).Result;
                return(Ok(html));
            }
            else
            {
                return(Ok("Nothing to display"));
            }
        }
예제 #2
0
        public async Task <ActionResult> Edit(long id)
        {
            var item = await _companyBusinessManager.GetCompany(id);

            if (item == null)
            {
                return(NotFound());
            }

            var sections = await _companyBusinessManager.GetSections(item.Id);

            ViewBag.Sections = _mapper.Map <List <CompanySectionViewModel> >(sections).ToList();

            return(View(_mapper.Map <CompanyViewModel>(item)));
        }