Exemplo n.º 1
0
        public ActionResult Edit(Guid id)
        {
            var userMail = User.Identity.Name;
            var employee = employeeService.GetAll(f => f.Email == userMail).FirstOrDefault();
            var companyEmployeeEmails = (companyService.GetAll(f => f.Id == employee.CompanyId).FirstOrDefault()).Employees.Select(s => s.Email).ToList(); // birden fazla yönetici ülke ekleyince gösteriyor mu ?
            var cities = new List <City>();

            foreach (var emailItem in companyEmployeeEmails)
            {
                var countries = countryService.GetAll(c => c.CreatedBy == emailItem).Select(s => s.Id);// Bu kısma online kullanıcının şirketindeki yöneticilerin ve kendisinin eklediği ülkelerin Id si.
                foreach (var countriesItem in countries)
                {
                    var citiesItem = cityService.GetAll(c => c.CountryId == countriesItem);
                    cities.AddRange(citiesItem);
                }
            }
            ViewBag.CityId = new SelectList(cities, "Id", "Name");
            var county          = countyService.Find(id);
            var countyViewModel = Mapper.Map <CountyViewModel>(county);

            if (countyViewModel == null)
            {
                return(HttpNotFound());
            }
            return(View(countyViewModel));
        }