public ActionResult Index()
        {
            TenantControl tenant = new TenantControl
            {
                Id           = -1,
                TenantUser   = "******",
                Theme        = "default",
                TenantSchema = "default"
            };

            if (Request.IsAuthenticated)
            {
                using (var db = new DefaultConnection()) {
                    string username = User.Identity.Name.Trim().ToLower();
                    var    idata    = db.TenantControl.FirstOrDefault(c => c.TenantUser.ToLower() == username);
                    if (idata != null)
                    {
                        tenant = idata;
                    }
                }
            }
            if (!tenant.TenantSchema.Equals("default"))
            {
            }
            return(View(tenant));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            TenantControl tenantControl = db.TenantControl.Find(id);

            db.TenantControl.Remove(tenantControl);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,TenantUser,Theme,TenantSchema,TenantConnection")] TenantControl tenantControl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tenantControl).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tenantControl));
 }
        public ActionResult Create([Bind(Include = "Id,TenantUser,Theme,TenantSchema,TenantConnection")] TenantControl tenantControl)
        {
            if (ModelState.IsValid)
            {
                db.TenantControl.Add(tenantControl);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tenantControl));
        }
 private bool checkNull(TenantControl tc)
 {
     if (tc == null)
     {
         return(true);
     }
     if (tc.Id == -1 || tc.TenantSchema != getTenantRouting())
     {
         return(true);
     }
     return(false);
 }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TenantControl tenantControl = db.TenantControl.Find(id);

            if (tenantControl == null)
            {
                return(HttpNotFound());
            }
            return(View(tenantControl));
        }
Ejemplo n.º 7
0
        private TenantControl getTenantControl()
        {
            TenantControl tenant = new TenantControl
            {
                Id           = -1,
                TenantUser   = "******",
                Theme        = "default",
                TenantSchema = "default"
            };

            if (Request.IsAuthenticated)
            {
                using (var db = new DefaultConnection())
                {
                    string username = User.Identity.Name.Trim().ToLower();
                    tenant = db.TenantControl.FirstOrDefault(c => c.TenantUser.ToLower() == username);
                }
            }
            return(tenant);
        }