예제 #1
0
        public ActionResult Create(LeadViewModel lead)
        {
            if (ModelState.IsValid)
            {
                var entity = Mapper.Map <Lead>(lead);
                _leadService.Insert(entity);
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryId    = new SelectList(_countryService.GetAll(), "Id", "Name", lead.CountryId);
            ViewBag.CityId       = new SelectList(_cityService.GetAllByCountryId(lead.CountryId ?? Guid.NewGuid()), "Id", "Name", lead.CityId);
            ViewBag.RegionId     = new SelectList(_regionService.GetAllByCityId(lead.CityId ?? Guid.NewGuid()), "Id", "Name", lead.RegionId);
            ViewBag.LeadSourceId = new SelectList(_leadSourceService.GetAll(), "Id", "Name", lead.LeadSourceId);
            ViewBag.LeadStatusId = new SelectList(_leadStatusService.GetAll(), "Id", "Name", lead.LeadStatusId);
            ViewBag.SectorId     = new SelectList(_sectorService.GetAll(), "Id", "Name", lead.SectorId);
            return(View(lead));
        }