Ejemplo n.º 1
0
        public IActionResult SaveTenant([FromBody] TenantModel model)
        {
            if (model == null)
            {
                return(BadRequest("Error, Make sure tenant form is complete!"));
            }
            try
            {
                Tenant tenant = _contextUsers.Tenants.FirstOrDefault(id => id.TenantKey == model.TenantKey);

                if (tenant != null)
                {
                    return(BadRequest("Tenant with the key: " + model.TenantKey + " already exists"));
                }

                Tenant t = new Tenant();
                t.DateStamp  = DateTime.Now;
                t.TenantKey  = model.TenantKey;
                t.TenantName = model.TenantName;
                t.Reference  = model.Reference;

                _contextUsers.Tenants.Add(t);
                _contextUsers.SaveChanges();



                return(Ok());
            }
            catch (Exception Ex)
            {
                return(BadRequest("Something bad happened! " + Ex.Message));
            }
        }
Ejemplo n.º 2
0
        public async void SeedRoles()
        {
            string[] roles = new string[] { "STRATISQ", "ADMINISTRATOR", "USER", "GUEST" };

            foreach (string role in roles)
            {
                var r = _context.Roles.Where(u => u.Name == role).Any();

                if (r == false)
                {
                    _context.Roles.Add(new IdentityRole()
                    {
                        Name           = role,
                        NormalizedName = role.ToUpper()
                    });
                    _context.SaveChanges();
                }
            }
        }