public ActionResult Registro(RegistroPersonaViewModel viewModel) { AppendLists(viewModel); if (ModelState.IsValid) { var session = SessionFactory.GetCurrentSession(); // Attempt to register the user var model = _mappingEngine.Map<Persona>(viewModel); //Update not automapped properties model.Documento = new Documento { Numero = viewModel.DocumentoNumero, TipoDocumento = Enumeration.FromValue<TipoDocumento>(viewModel.TipoDocumentoId) }; model.Domicilio = new Domicilio { Direccion = viewModel.DomicilioDireccion, Localidad = session.Load<Localidad>(viewModel.DomicilioLocalidadId) }; var pacienteRol = Paciente.Create(viewModel.NumeroAfiliado); pacienteRol.Plan = session.Load<Plan>(viewModel.PlanId); model.AgregarRol(pacienteRol); var status = _membershipService.CreateUser(model, viewModel.Email, viewModel.Password); if (status == MembershipStatus.USER_CREATED) { _membershipService.Login(viewModel.Email, viewModel.Password, out model); ShowMessages(ResponseMessage.Success("Bienvenido a SICEMED {0}.", model.NombreCompleto)); return RedirectToAction("Index", "Content"); } ModelState.AddModelError("", status.Get()); } ViewBag.PasswordLength = _membershipService.MinPasswordLength; return View(viewModel); }
private void AppendLists(RegistroPersonaViewModel viewModel) { viewModel.TiposDocumentosHabilitados = GetTiposDocumentos(viewModel.TipoDocumentoId); viewModel.ProvinciasHabilitadas = GetProvincias(viewModel.DomicilioLocalidadProvinciaId); viewModel.ObrasSocialesHabilitadas = GetObrasSociales(viewModel.ObraSocialId); if (viewModel.DomicilioLocalidadProvinciaId.HasValue) viewModel.LocalidadesHabilitadas = GetLocalidadesPorProvincia(viewModel.DomicilioLocalidadProvinciaId.Value, viewModel.DomicilioLocalidadId); if (viewModel.ObraSocialId.HasValue) viewModel.PlanesObraSocialHabilitados = GetPlanesPorObraSocial(viewModel.ObraSocialId.Value, viewModel.PlanId); }
public ActionResult Registro() { ViewBag.PasswordLength = _membershipService.MinPasswordLength; var viewModel = new RegistroPersonaViewModel(); AppendLists(viewModel); return View(viewModel); }