Exemplo n.º 1
0
        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);
            var ctx = requestContext;

            TenantCode = (string)ctx.RouteData.Values["tenant"];
            if (string.IsNullOrEmpty(TenantCode))
            {
                var fullAddress = ctx.HttpContext.Request.Headers["Host"].Split('.');
                if (fullAddress.Length >= 2)
                {
                    ctx.RouteData.Values["tenant"] = fullAddress[0];
                    TenantCode = fullAddress[0];
                }
            }
            if (!string.IsNullOrEmpty(TenantCode) && TenantCode != Constants.Default.TenantCode)
            {
                var t = _repo.Single(TenantCode);

                if (!string.IsNullOrEmpty(t.ConnectionString))
                {
                    ConnectionString = t.ConnectionString;
                }
            }
        }
Exemplo n.º 2
0
 public ActionResult Edit(TenantViewModel vm)
 {
     if (ModelState.IsValid)
     {
         var entity = _repo.Single(vm.TenantCode);
         Mapper.Map(vm, entity);
         _repo.Update(entity);
         return(RedirectToAction("Index"));
     }
     return(Edit(vm.TenantCode));
 }