public ActionResult Autorize(string mail, string pass, string returnUrl) { var model = new Models.Authentication.IndexVM(); model.UserMail = mail; var authBll = new Domain.BLL.AuthenticationBLL(); var user = authBll.Authorize(mail); if (user != null) { if (user.Senha == new Utils.Cryptography.EncryptMd5().GetHash(pass)) { var peopleBll = new Domain.BLL.PeopleBLL(); user.PessoaEmpresas = peopleBll.GetPeopleCustomers(user.ID); var customerBll = new Domain.BLL.CustomerBLL(); foreach (var peopleCustomer in user.PessoaEmpresas) { peopleCustomer.Empresas = customerBll.GetCustomer(peopleCustomer.EmpresaId); } Session.SetLoggedUser(user); //Let us now set the authentication cookie so that we can use that later. FormsAuthentication.SetAuthCookie(mail, false); return RedirectToAction("Index", "Home"); } else { model.Error = "Senha Inválida"; } } else { model.Error = "Email não encontrado"; } return RedirectToAction("Index", new { error = model.Error }); }
public ActionResult GetPeopleDetail(long peopleId) { var peopleBll = new Domain.BLL.PeopleBLL(); var customerBll = new Domain.BLL.CustomerBLL(); var people = peopleBll.Get(peopleId); var peopleCustomers = peopleBll.GetPeopleCustomers(peopleId).Select(pe => new { peopleType = peopleBll.GetPeopleType(pe.PessoaTipoId).Descricao, customer = customerBll.GetCustomer(pe.EmpresaId).Nome }).ToList(); var picture = new Domain.BLL.ImagesBLL().GetNoImage().Url; if (people.ImagemId.HasValue) { picture = new ImagesBLL().Get(people.ImagemId.Value).Url; } var result = new { customers = peopleCustomers, picture = picture }; return Json(result, JsonRequestBehavior.AllowGet); }