public ActionResult Empresa(string database, EmpresaModel model) { ViewBag.database = database; if (ModelState.IsValid) { var context = new ContextService(); context.BaseDatos = database; using (var service = new StartupService(context, database)) { try { if (model != null) { var nModel = Helper.fModel.GetModel <EmpresaModel>(context, service.Db); model.Paises = nModel.Paises; model.PlanesGenerales = nModel.PlanesGenerales; var aux = Helper.fModel.GetModel <EmpresaModel>(context, service.Db); model.PlanesGenerales = aux.PlanesGenerales; model.Paises = aux.Paises; model.LstTarifasVentas = aux.LstTarifasVentas; model.LstTarifasCompras = aux.LstTarifasCompras; service.CreateEmpresa(model); using (var loginService = new LoginService()) { HttpCookie securityCookie; FormsAuthentication.SignOut(); loginService.Forzardesconexion(database, ApplicationHelper.UsuariosAdministrador); loginService.SetEmpresaUserAdmin(_dominio, database, model.Id, string.Empty, string.Empty, Guid.NewGuid(), out securityCookie); Response.Cookies.Add(securityCookie); } } return(RedirectToAction("Index", "Home")); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } } return(View(model)); }