public ActionResult Edit(int peopleId = 0, string mail = null) { var model = new Models.People.EditVM(); model.States = new Utils.Cep.Estados().GetAll(); var peopleBll = new Domain.BLL.PeopleBLL(); model.PeopleCustomers = new List<Domain.Repository.PessoaEmpresas>(); model.Image = new Domain.Repository.Imagens { Url = "/Uploads/Images/no-image.png" }; foreach (var peopleCustomerUser in Session.GetLoggedUser().PessoaEmpresas.ToList()) { if (peopleCustomerUser.PessoaTipoId > 2) { var peopleCustomerEdit = peopleBll.GetPeopleCustomer(peopleId, peopleCustomerUser.EmpresaId); if (peopleCustomerEdit == null) { peopleCustomerEdit = new Domain.Repository.PessoaEmpresas(); peopleCustomerEdit.EmpresaId = peopleCustomerUser.EmpresaId; peopleCustomerEdit.Empresas = peopleCustomerUser.Empresas; } else { peopleCustomerEdit.Empresas = Session.GetLoggedUser().PessoaEmpresas.ToList().Where(pe => pe.EmpresaId == peopleCustomerEdit.EmpresaId).FirstOrDefault().Empresas; } model.PeopleCustomers.Add(peopleCustomerEdit); } } if (peopleId == 0) { model.People = new Domain.Repository.Pessoas(); if (!string.IsNullOrEmpty(mail)) { model.People.Email = mail; } } else { model.People = peopleBll.GetPeople(peopleId); if (model.People.ImagemId.HasValue) { model.Image = new Domain.BLL.ImagesBLL().Get(model.People.ImagemId.Value); } } model.PeopleTypes = peopleBll.GetPeopleTypes(); return View(model); }
public ActionResult Index() { var model = new Models.People.IndexVM(); var peopleBll = new Domain.BLL.PeopleBLL(); model.PeopleTypes = peopleBll.GetPeopleTypes(); model.LoggedUser = Session.GetLoggedUser(); return View(model); }