示例#1
0
        // GET: Companies/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CompanyTO company = cmpRepo.getAllCompanybyId(id);

            List <UserAccess> userAccess = cmpRepo.getAllUserAccess().Where(x => x.CompanyId == id).ToList();
            List <int>        userRoleId = new List <int>();

            foreach (var item in userAccess)
            {
                userRoleId.Add(item.UserRoleId);
            }

            var userRolesIsAdmin = cmpRepo.getAllUserrole().Where(c => userRoleId.Contains(c.UserRoleId)).Select(x => new { x.EmailId, x.IsAdmin }).ToList();

            //string contactEmailId=


            company.Company_Admin    = userRolesIsAdmin.Where(x => x.IsAdmin == true).Select(x => x.EmailId).FirstOrDefault();
            company.Company_Contacts = userRolesIsAdmin.Where(x => x.IsAdmin == false).Select(x => x.EmailId).FirstOrDefault();

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