public JsonResult ReLogin(string token, string mail) { var authBll = new Domain.BLL.AuthenticationBLL(); var peopleToken = authBll.ReLogin(token, mail); if (peopleToken != null) { var people = new Domain.BLL.PeopleBLL().GetPeople(mail); FormsAuthentication.SetAuthCookie(people.Email, false); Session.SetLoggedUser(people); return Json(new { success = true, token = new { expiration = peopleToken.Vencimento.ToString("dd/MM/yyyy HH:mm:ss"), } }, JsonRequestBehavior.AllowGet); } return Json(new { success = false, error = "Token não encontrado ou vencido" }, JsonRequestBehavior.AllowGet); }
public long AddFriend(long peopleId) { var loggedUser = Session.GetLoggedUser(); var peopleBll = new Domain.BLL.PeopleBLL(); var peopleFriends = peopleBll.AddPeopleFriend(loggedUser.ID, peopleId); return peopleFriends.ID; }
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 ChangePassword(string newPassword) { var loggedUser = Session.GetLoggedUser(); loggedUser.Senha = new Utils.Cryptography.EncryptMd5().GetHash(newPassword); loggedUser = new Domain.BLL.PeopleBLL().Save(loggedUser); Session.SetLoggedUser(loggedUser); return RedirectToAction("Index", "Home"); }
// // GET: /Chat/ public ActionResult Index() { var model = new Models.Chat.indexVM(); var loggedUser = Session.GetLoggedUser(); var peopleBll = new Domain.BLL.PeopleBLL(); var chatBll = new Domain.BLL.ChatBLL(); model.Friends = peopleBll.GetPeopleFriends(loggedUser.ID); model.FriendsChat = chatBll.GetFriendsWithMessage(loggedUser.ID); return View(model); }
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 bool VerifeMail(string mail) { var peopleBll = new Domain.BLL.PeopleBLL(); var people = peopleBll.GetPeople(mail); var success = false; if (people == null) { success = true; } return success; }
public long SaveCustomerRequest(int customerId, string email) { var loggedUser = Session.GetLoggedUser(); if (loggedUser != null) { var peopleBll = new Domain.BLL.PeopleBLL(); var people = peopleBll.GetPeople(email); if (people == null) { throw new Exception("Email não encontrado"); } var customer = loggedUser.PessoaEmpresas.Where(pe => pe.EmpresaId == customerId).FirstOrDefault(); if (customer == null) { throw new Exception("Usuario logado nao tem acesso a solicitar vinculação para essa empresa"); } var peopleRequestBll = new Domain.BLL.PeopleRequest.PeopleRequestBLL(); var customerRequest = peopleRequestBll.GetPendingPeopleCustomerRequest(people.ID, customerId); if (customerRequest == null) { customerRequest = new Domain.Repository.PessoaSolicitacoes(); customerRequest.DataSolicitacao = DateTime.Now; customerRequest.Descricao = "A Empresa " + customer.Empresas.Nome + " esta solicitando acesso ao seus dados cadastrais, acesso para habilitar o seu cadastro como aluno"; customerRequest.Titulo = "Solicitacao de acesso"; customerRequest.PessoaId = people.ID; customerRequest.PessoaSolicitacaoTipoId = (int)Domain.BLL.PeopleRequest.PeopleRequestTypes.CustomerRequest; customerRequest.PessoaSolicitacaoEmpresa = new List<Domain.Repository.PessoaSolicitacaoEmpresa>(); customerRequest.PessoaSolicitacaoEmpresa.Add(new Domain.Repository.PessoaSolicitacaoEmpresa { EmpresaId = customerId }); } else { throw new Exception("Já existe uma solicitação pendente para essa pessoa"); } return peopleBll.RequestSave(customerRequest).ID; } throw new Exception("Usuario não identificado"); }
public long Save(string jsonPeople) { var format = "dd/MM/yyyy"; // your datetime format var dateTimeConverter = new IsoDateTimeConverter { DateTimeFormat = format }; var people = JsonConvert.DeserializeObject<Domain.Repository.Pessoas>(jsonPeople, dateTimeConverter); if (people.ImagemId <= 0) { people.ImagemId = null; } people = new Domain.BLL.PeopleBLL().Save(people); if (people.ImagemId.HasValue) { var loggedUser = Session.GetLoggedUser(); if (people.ID == loggedUser.ID) { //var image = new Domain.BLL.ImagesBLL().Get(people.ImagemId.Value); loggedUser.ImagemId = people.ImagemId; } } return people.ID; }
public ActionResult List(int peopleTypeId, string peopleName, string peopleCpf) { var model = new Models.People.ListVM(); var peopleBll = new Domain.BLL.PeopleBLL(); model.Peoples = peopleBll.GetPeoples(Session.GetLoggedUser().ID, peopleTypeId, peopleName, peopleCpf); 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); }
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); }
public ActionResult GetPeopleAheadAjax(string search) { var exerciseBll = new Domain.BLL.ExerciseBLL(); var loggedUser = Session.GetLoggedUser(); var peoples = new Domain.BLL.PeopleBLL().GetPeopleByFilter(search).Where(p => p.ID != loggedUser.ID).ToList(); var response = peoples.Select(p => new { description = p.Nome + " " + p.Sobrenome, ID = p.ID }).ToList(); return Json(response, JsonRequestBehavior.AllowGet); }
public ActionResult PeoplesList(string name, string cpf) { var model = new Models.Trainig.PeoplesListVM(); var loggedUser = Session.GetLoggedUser(); var peopleBll = new Domain.BLL.PeopleBLL(); model.Peoples = peopleBll.GetStudentPeople(loggedUser.PessoaEmpresas, name, cpf); var professorIds = model.Peoples.Where(p => p.ProfessorPessoaId.HasValue).GroupBy(p => p.ProfessorPessoaId).Select(p => p.First().ProfessorPessoaId.Value).ToList(); model.Professors = peopleBll.GetProfessors(professorIds); return View(model); }
public ActionResult PeopleDetails(long peopleId) { var model = new Models.Trainig.PeopleDetailsVM(); var peopleBll = new Domain.BLL.PeopleBLL(); var trainningBll = new Domain.BLL.TrainningBLL(); model.People = peopleBll.GetPeople(peopleId); model.Professor = peopleBll.GetPeople(model.People.ProfessorPessoaId.Value); model.Trainnings = trainningBll.GetTrainnings(peopleId); if (model.People.ImagemId.HasValue) { model.People.Imagens = new Domain.BLL.ImagesBLL().Get(model.People.ImagemId.Value); } if (model.People.Imagens == null) { model.People.Imagens = new Domain.Repository.Imagens { Url = "/Uploads/Images/no-image.png" }; } return View(model); }